@pisell/pisellos 2.2.174 → 2.2.176
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/Order/index.d.ts +52 -1
- package/dist/modules/Order/index.js +730 -348
- package/dist/modules/Order/types.d.ts +140 -1
- package/dist/modules/Order/types.js +29 -0
- package/dist/modules/Order/utils.d.ts +11 -0
- package/dist/modules/Order/utils.js +43 -2
- package/dist/modules/SalesSummary/utils.js +3 -3
- package/dist/server/index.js +77 -23
- package/dist/solution/BaseSales/index.d.ts +37 -1
- package/dist/solution/BaseSales/index.js +751 -457
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +1258 -0
- package/dist/solution/BookingTicket/index.js +4 -0
- package/dist/solution/BookingTicket/utils/cartView.js +4 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +52 -1
- package/lib/modules/Order/index.js +195 -6
- package/lib/modules/Order/types.d.ts +140 -1
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +11 -0
- package/lib/modules/Order/utils.js +34 -2
- package/lib/modules/SalesSummary/utils.js +3 -3
- package/lib/server/index.js +39 -4
- package/lib/solution/BaseSales/index.d.ts +37 -1
- package/lib/solution/BaseSales/index.js +207 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +275 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +836 -0
- package/lib/solution/BookingTicket/index.js +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +4 -2
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ import { BaseSalesHookNames } from "./types";
|
|
|
31
31
|
import { OrderModule } from "../../modules/Order";
|
|
32
32
|
import Decimal from 'decimal.js';
|
|
33
33
|
import { createModule } from "../BookingByStep/types";
|
|
34
|
-
import { composeLinePrice, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
34
|
+
import { composeLinePrice, createUuidV4, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
35
35
|
import dayjs from 'dayjs';
|
|
36
36
|
export * from "./types";
|
|
37
37
|
import { QuotationModule } from "../../modules/Quotation";
|
|
@@ -182,11 +182,199 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
182
182
|
}
|
|
183
183
|
return loadQuotationForPriceQuery;
|
|
184
184
|
}()
|
|
185
|
+
}, {
|
|
186
|
+
key: "getPriceQueryProductId",
|
|
187
|
+
value: function getPriceQueryProductId(product) {
|
|
188
|
+
var _product$product_id;
|
|
189
|
+
var productId = Number((_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product === null || product === void 0 ? void 0 : product.id);
|
|
190
|
+
if (!Number.isFinite(productId)) return null;
|
|
191
|
+
return productId;
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getPriceQuerySchedule",
|
|
195
|
+
value: function getPriceQuerySchedule(params) {
|
|
196
|
+
var booking = params.booking || {};
|
|
197
|
+
if (typeof booking.start_date === 'string' && booking.start_date.trim()) {
|
|
198
|
+
var scheduleDate = booking.start_date.trim();
|
|
199
|
+
var startTime = typeof booking.start_time === 'string' && booking.start_time.trim() ? booking.start_time.trim() : '00:00:00';
|
|
200
|
+
var datetime = dayjs("".concat(scheduleDate, " ").concat(startTime));
|
|
201
|
+
return {
|
|
202
|
+
schedule_date: scheduleDate,
|
|
203
|
+
schedule_datetime: datetime.isValid() ? datetime.format('YYYY-MM-DD HH:mm:ss') : "".concat(scheduleDate, " ").concat(startTime)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (typeof params.datetime === 'string' && params.datetime.trim()) {
|
|
207
|
+
var _datetime = dayjs(params.datetime.trim());
|
|
208
|
+
if (_datetime.isValid()) {
|
|
209
|
+
return {
|
|
210
|
+
schedule_date: _datetime.format('YYYY-MM-DD'),
|
|
211
|
+
schedule_datetime: _datetime.format('YYYY-MM-DD HH:mm:ss')
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
var now = dayjs();
|
|
216
|
+
return {
|
|
217
|
+
schedule_date: now.format('YYYY-MM-DD'),
|
|
218
|
+
schedule_datetime: now.format('YYYY-MM-DD HH:mm:ss')
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}, {
|
|
222
|
+
key: "loadProductForPriceQuery",
|
|
223
|
+
value: function () {
|
|
224
|
+
var _loadProductForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params, customerId) {
|
|
225
|
+
var product, productId, schedule, _this$otherParams2, _response$data, response, list;
|
|
226
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
227
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
228
|
+
case 0:
|
|
229
|
+
product = params.product || {};
|
|
230
|
+
productId = this.getPriceQueryProductId(product);
|
|
231
|
+
if (!(productId === null || !this.request)) {
|
|
232
|
+
_context2.next = 4;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
return _context2.abrupt("return", null);
|
|
236
|
+
case 4:
|
|
237
|
+
schedule = this.getPriceQuerySchedule(params);
|
|
238
|
+
_context2.prev = 5;
|
|
239
|
+
_context2.next = 8;
|
|
240
|
+
return this.request.post('/product/query', {
|
|
241
|
+
ids: [productId],
|
|
242
|
+
open_quotation: 1,
|
|
243
|
+
open_bundle: 1,
|
|
244
|
+
status: 'published',
|
|
245
|
+
num: 1,
|
|
246
|
+
skip: 1,
|
|
247
|
+
customer_id: customerId,
|
|
248
|
+
schedule_date: schedule.schedule_date,
|
|
249
|
+
schedule_datetime: schedule.schedule_datetime,
|
|
250
|
+
application_code: params.channel || ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.channel)
|
|
251
|
+
}, {
|
|
252
|
+
osServer: true,
|
|
253
|
+
customToast: function customToast() {}
|
|
254
|
+
});
|
|
255
|
+
case 8:
|
|
256
|
+
response = _context2.sent;
|
|
257
|
+
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
258
|
+
if (Array.isArray(list)) {
|
|
259
|
+
_context2.next = 12;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
return _context2.abrupt("return", null);
|
|
263
|
+
case 12:
|
|
264
|
+
return _context2.abrupt("return", list.find(function (item) {
|
|
265
|
+
var _item$id;
|
|
266
|
+
return Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id) === productId;
|
|
267
|
+
}) || null);
|
|
268
|
+
case 15:
|
|
269
|
+
_context2.prev = 15;
|
|
270
|
+
_context2.t0 = _context2["catch"](5);
|
|
271
|
+
this.logWarning('loadProductForPriceQuery: 商品重查失败,使用入参 fallback', {
|
|
272
|
+
productId: productId,
|
|
273
|
+
error: _context2.t0 instanceof Error ? _context2.t0.message : String(_context2.t0)
|
|
274
|
+
});
|
|
275
|
+
return _context2.abrupt("return", null);
|
|
276
|
+
case 19:
|
|
277
|
+
case "end":
|
|
278
|
+
return _context2.stop();
|
|
279
|
+
}
|
|
280
|
+
}, _callee2, this, [[5, 15]]);
|
|
281
|
+
}));
|
|
282
|
+
function loadProductForPriceQuery(_x2, _x3) {
|
|
283
|
+
return _loadProductForPriceQuery.apply(this, arguments);
|
|
284
|
+
}
|
|
285
|
+
return loadProductForPriceQuery;
|
|
286
|
+
}()
|
|
287
|
+
}, {
|
|
288
|
+
key: "getAuthoritativeBundleItems",
|
|
289
|
+
value: function getAuthoritativeBundleItems(product) {
|
|
290
|
+
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product.product_bundle;
|
|
291
|
+
var groups = Array.isArray(product === null || product === void 0 ? void 0 : product.bundle_group) ? product.bundle_group : Array.isArray(product === null || product === void 0 ? void 0 : product.bundleGroup) ? product.bundleGroup : [];
|
|
292
|
+
return groups.flatMap(function (group) {
|
|
293
|
+
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
294
|
+
return items.map(function (item) {
|
|
295
|
+
var _item$group_id, _ref, _item$bundle_group_id;
|
|
296
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
297
|
+
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
298
|
+
bundle_group_id: (_ref = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref !== void 0 ? _ref : group === null || group === void 0 ? void 0 : group.id
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}, {
|
|
304
|
+
key: "findAuthoritativeBundleItem",
|
|
305
|
+
value: function findAuthoritativeBundleItem(bundle, candidates) {
|
|
306
|
+
var _bundle$bundle_id, _bundle$bundle_produc, _bundle$bundle_group_;
|
|
307
|
+
var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
|
|
308
|
+
if (bundleId != null) {
|
|
309
|
+
var matchedById = candidates.find(function (item) {
|
|
310
|
+
var _item$bundle_id;
|
|
311
|
+
return String((_item$bundle_id = item === null || item === void 0 ? void 0 : item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item === null || item === void 0 ? void 0 : item.id) === String(bundleId);
|
|
312
|
+
});
|
|
313
|
+
if (matchedById) return matchedById;
|
|
314
|
+
}
|
|
315
|
+
var productId = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id;
|
|
316
|
+
var groupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
317
|
+
return candidates.find(function (item) {
|
|
318
|
+
var _item$bundle_product_, _item$bundle_group_id2;
|
|
319
|
+
var itemProductId = (_item$bundle_product_ = item === null || item === void 0 ? void 0 : item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item === null || item === void 0 ? void 0 : item._bundle_product_id;
|
|
320
|
+
var itemGroupId = (_item$bundle_group_id2 = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id2 !== void 0 ? _item$bundle_group_id2 : item === null || item === void 0 ? void 0 : item.group_id;
|
|
321
|
+
if (productId == null || String(itemProductId) !== String(productId)) return false;
|
|
322
|
+
if (groupId == null) return true;
|
|
323
|
+
return String(itemGroupId) === String(groupId);
|
|
324
|
+
}) || null;
|
|
325
|
+
}
|
|
326
|
+
}, {
|
|
327
|
+
key: "getAuthoritativeBundleUnitPrice",
|
|
328
|
+
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
329
|
+
var _ref2, _ref3, _ref4, _bundle$price;
|
|
330
|
+
return (_ref2 = (_ref3 = (_ref4 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref4 !== void 0 ? _ref4 : bundle.custom_price) !== null && _ref3 !== void 0 ? _ref3 : bundle.product_price) !== null && _ref2 !== void 0 ? _ref2 : bundle.base_price;
|
|
331
|
+
}
|
|
332
|
+
}, {
|
|
333
|
+
key: "mergeProductForPriceQuery",
|
|
334
|
+
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
335
|
+
var _this2 = this,
|
|
336
|
+
_product$id,
|
|
337
|
+
_ref5,
|
|
338
|
+
_product$product_id2,
|
|
339
|
+
_ref6,
|
|
340
|
+
_product$product_vari,
|
|
341
|
+
_ref7,
|
|
342
|
+
_product$num,
|
|
343
|
+
_ref8,
|
|
344
|
+
_product$quantity,
|
|
345
|
+
_product$product_opti,
|
|
346
|
+
_product$metadata;
|
|
347
|
+
if (!authoritativeProduct) return product;
|
|
348
|
+
var selectedBundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
349
|
+
var authoritativeBundles = this.getAuthoritativeBundleItems(authoritativeProduct);
|
|
350
|
+
var productBundle = selectedBundles.map(function (bundle) {
|
|
351
|
+
var _authoritativeBundle$, _authoritativeBundle$2;
|
|
352
|
+
var authoritativeBundle = _this2.findAuthoritativeBundleItem(bundle, authoritativeBundles);
|
|
353
|
+
var unitPrice = authoritativeBundle ? _this2.getAuthoritativeBundleUnitPrice(authoritativeBundle) : undefined;
|
|
354
|
+
if (unitPrice === undefined || unitPrice === null || unitPrice === '') return bundle;
|
|
355
|
+
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
356
|
+
price: unitPrice,
|
|
357
|
+
bundle_selling_price: unitPrice,
|
|
358
|
+
base_price: (_authoritativeBundle$ = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.base_price) !== null && _authoritativeBundle$ !== void 0 ? _authoritativeBundle$ : bundle.base_price,
|
|
359
|
+
product_price: (_authoritativeBundle$2 = authoritativeBundle === null || authoritativeBundle === void 0 ? void 0 : authoritativeBundle.product_price) !== null && _authoritativeBundle$2 !== void 0 ? _authoritativeBundle$2 : bundle.product_price
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
363
|
+
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
364
|
+
product_id: (_ref5 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref5 !== void 0 ? _ref5 : authoritativeProduct.id,
|
|
365
|
+
product_variant_id: (_ref6 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref6 !== void 0 ? _ref6 : 0,
|
|
366
|
+
num: (_ref7 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref7 !== void 0 ? _ref7 : authoritativeProduct.num,
|
|
367
|
+
quantity: (_ref8 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref8 !== void 0 ? _ref8 : authoritativeProduct.quantity,
|
|
368
|
+
product_option_item: (_product$product_opti = product.product_option_item) !== null && _product$product_opti !== void 0 ? _product$product_opti : authoritativeProduct.product_option_item,
|
|
369
|
+
product_bundle: productBundle,
|
|
370
|
+
metadata: (_product$metadata = product.metadata) !== null && _product$metadata !== void 0 ? _product$metadata : authoritativeProduct.metadata
|
|
371
|
+
});
|
|
372
|
+
}
|
|
185
373
|
}, {
|
|
186
374
|
key: "getSubmitOrderSalesChannel",
|
|
187
375
|
value: function getSubmitOrderSalesChannel() {
|
|
188
|
-
var _this$
|
|
189
|
-
return (_this$
|
|
376
|
+
var _this$otherParams3;
|
|
377
|
+
return (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
|
|
190
378
|
}
|
|
191
379
|
|
|
192
380
|
/**
|
|
@@ -246,10 +434,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
246
434
|
}, {
|
|
247
435
|
key: "syncAppDataToTempOrder",
|
|
248
436
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
437
|
+
var isPriceIncludeTax = this.getAppData('is_price_include_tax');
|
|
249
438
|
var taxCountryCode = this.getAppData('tax_country_code');
|
|
250
439
|
var currencyCode = this.getAppData('shop_currency_code');
|
|
251
440
|
var currencySymbol = this.getAppData('shop_symbol');
|
|
252
441
|
var isChanged = false;
|
|
442
|
+
if (isPriceIncludeTax !== undefined) {
|
|
443
|
+
var nextIsPriceIncludeTax = Number(isPriceIncludeTax);
|
|
444
|
+
if ((nextIsPriceIncludeTax === 0 || nextIsPriceIncludeTax === 1) && tempOrder.is_price_include_tax !== nextIsPriceIncludeTax) {
|
|
445
|
+
tempOrder.is_price_include_tax = nextIsPriceIncludeTax;
|
|
446
|
+
isChanged = true;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
253
449
|
if (taxCountryCode !== undefined) {
|
|
254
450
|
var nextTaxCountryCode = String(taxCountryCode || '');
|
|
255
451
|
if (tempOrder.tax_country_code !== nextTaxCountryCode) {
|
|
@@ -276,30 +472,30 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
276
472
|
}, {
|
|
277
473
|
key: "initialize",
|
|
278
474
|
value: function () {
|
|
279
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
280
|
-
var _this$
|
|
281
|
-
|
|
475
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(core) {
|
|
476
|
+
var _this$otherParams4,
|
|
477
|
+
_this3 = this;
|
|
282
478
|
var options,
|
|
283
479
|
app,
|
|
284
480
|
targetCacheData,
|
|
285
481
|
moduleNames,
|
|
286
|
-
|
|
287
|
-
return _regeneratorRuntime().wrap(function
|
|
288
|
-
while (1) switch (
|
|
482
|
+
_args3 = arguments;
|
|
483
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
484
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
289
485
|
case 0:
|
|
290
|
-
options =
|
|
486
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
291
487
|
this.core = core;
|
|
292
488
|
this.initializeOptions = options || {};
|
|
293
489
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
294
490
|
this.otherParams = options.otherParams || {};
|
|
295
|
-
this.cacheId = (_this$
|
|
491
|
+
this.cacheId = (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.cacheId;
|
|
296
492
|
this.window = core.getPlugin('window');
|
|
297
493
|
this.request = core.getPlugin('request');
|
|
298
494
|
|
|
299
495
|
// 获取 logger 实例
|
|
300
496
|
this.appPlugin = core.getPlugin('app');
|
|
301
497
|
if (this.appPlugin) {
|
|
302
|
-
|
|
498
|
+
_context3.next = 10;
|
|
303
499
|
break;
|
|
304
500
|
}
|
|
305
501
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
@@ -309,40 +505,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
309
505
|
targetCacheData = this.readSessionCacheData();
|
|
310
506
|
moduleNames = this.getRegisteredModuleNames();
|
|
311
507
|
moduleNames.forEach(function (step) {
|
|
312
|
-
var targetModule =
|
|
508
|
+
var targetModule = _this3.createSubModule(step);
|
|
313
509
|
if (!targetModule) {
|
|
314
510
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
315
511
|
}
|
|
316
|
-
var hooks =
|
|
317
|
-
|
|
318
|
-
|
|
512
|
+
var hooks = _this3.getSubModuleHooks(step);
|
|
513
|
+
_this3.store[step] = targetModule;
|
|
514
|
+
_this3.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
319
515
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
320
516
|
}, hooks ? {
|
|
321
517
|
hooks: hooks
|
|
322
518
|
} : {}), {}, {
|
|
323
|
-
otherParams: _objectSpread(_objectSpread({},
|
|
324
|
-
salesSummaryModuleName: "".concat(
|
|
325
|
-
fatherModule:
|
|
326
|
-
openCache:
|
|
327
|
-
cacheId:
|
|
519
|
+
otherParams: _objectSpread(_objectSpread({}, _this3.otherParams), {}, {
|
|
520
|
+
salesSummaryModuleName: "".concat(_this3.name, "_salesSummary"),
|
|
521
|
+
fatherModule: _this3.name,
|
|
522
|
+
openCache: _this3.cacheId ? true : false,
|
|
523
|
+
cacheId: _this3.cacheId
|
|
328
524
|
})
|
|
329
525
|
}));
|
|
330
526
|
});
|
|
331
527
|
if (!this.store.schedule) {
|
|
332
|
-
|
|
528
|
+
_context3.next = 18;
|
|
333
529
|
break;
|
|
334
530
|
}
|
|
335
|
-
|
|
531
|
+
_context3.next = 18;
|
|
336
532
|
return this.store.schedule.loadAllSchedule();
|
|
337
533
|
case 18:
|
|
338
534
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
339
535
|
case 19:
|
|
340
536
|
case "end":
|
|
341
|
-
return
|
|
537
|
+
return _context3.stop();
|
|
342
538
|
}
|
|
343
|
-
},
|
|
539
|
+
}, _callee3, this);
|
|
344
540
|
}));
|
|
345
|
-
function initialize(
|
|
541
|
+
function initialize(_x4) {
|
|
346
542
|
return _initialize.apply(this, arguments);
|
|
347
543
|
}
|
|
348
544
|
return initialize;
|
|
@@ -350,13 +546,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
350
546
|
}, {
|
|
351
547
|
key: "destroy",
|
|
352
548
|
value: function () {
|
|
353
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
354
|
-
var
|
|
355
|
-
return _regeneratorRuntime().wrap(function
|
|
356
|
-
while (1) switch (
|
|
549
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
550
|
+
var _this4 = this;
|
|
551
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
552
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
357
553
|
case 0:
|
|
358
554
|
Object.keys(this.store).forEach(function (key) {
|
|
359
|
-
var sub =
|
|
555
|
+
var sub = _this4.store[key];
|
|
360
556
|
if (sub && typeof sub.destroy === 'function') {
|
|
361
557
|
try {
|
|
362
558
|
sub.destroy();
|
|
@@ -366,15 +562,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
366
562
|
}
|
|
367
563
|
});
|
|
368
564
|
this.currentSalesDetail = null;
|
|
369
|
-
|
|
565
|
+
_context4.next = 4;
|
|
370
566
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
371
567
|
case 4:
|
|
372
568
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
373
569
|
case 5:
|
|
374
570
|
case "end":
|
|
375
|
-
return
|
|
571
|
+
return _context4.stop();
|
|
376
572
|
}
|
|
377
|
-
},
|
|
573
|
+
}, _callee4, this);
|
|
378
574
|
}));
|
|
379
575
|
function destroy() {
|
|
380
576
|
return _destroy.apply(this, arguments);
|
|
@@ -391,13 +587,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
391
587
|
}, {
|
|
392
588
|
key: "loadSalesDetail",
|
|
393
589
|
value: (function () {
|
|
394
|
-
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
590
|
+
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderIdOrParams) {
|
|
395
591
|
var params, externalSaleNumber, localRecord, _sales, res, message, sales;
|
|
396
|
-
return _regeneratorRuntime().wrap(function
|
|
397
|
-
while (1) switch (
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
593
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
398
594
|
case 0:
|
|
399
595
|
if (this.store.order) {
|
|
400
|
-
|
|
596
|
+
_context5.next = 2;
|
|
401
597
|
break;
|
|
402
598
|
}
|
|
403
599
|
throw new Error('order 模块未初始化');
|
|
@@ -407,107 +603,107 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
407
603
|
};
|
|
408
604
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
409
605
|
if (params.forceRemote) {
|
|
410
|
-
|
|
606
|
+
_context5.next = 35;
|
|
411
607
|
break;
|
|
412
608
|
}
|
|
413
609
|
if (!(params.orderId !== undefined)) {
|
|
414
|
-
|
|
610
|
+
_context5.next = 11;
|
|
415
611
|
break;
|
|
416
612
|
}
|
|
417
|
-
|
|
613
|
+
_context5.next = 8;
|
|
418
614
|
return this.store.order.getLocalOrderByOrderId(params.orderId);
|
|
419
615
|
case 8:
|
|
420
|
-
|
|
421
|
-
|
|
616
|
+
_context5.t0 = _context5.sent;
|
|
617
|
+
_context5.next = 26;
|
|
422
618
|
break;
|
|
423
619
|
case 11:
|
|
424
620
|
if (!externalSaleNumber) {
|
|
425
|
-
|
|
621
|
+
_context5.next = 17;
|
|
426
622
|
break;
|
|
427
623
|
}
|
|
428
|
-
|
|
624
|
+
_context5.next = 14;
|
|
429
625
|
return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
|
|
430
626
|
case 14:
|
|
431
|
-
|
|
432
|
-
|
|
627
|
+
_context5.t1 = _context5.sent;
|
|
628
|
+
_context5.next = 25;
|
|
433
629
|
break;
|
|
434
630
|
case 17:
|
|
435
631
|
if (!params.orderNumber) {
|
|
436
|
-
|
|
632
|
+
_context5.next = 23;
|
|
437
633
|
break;
|
|
438
634
|
}
|
|
439
|
-
|
|
635
|
+
_context5.next = 20;
|
|
440
636
|
return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
|
|
441
637
|
case 20:
|
|
442
|
-
|
|
443
|
-
|
|
638
|
+
_context5.t2 = _context5.sent;
|
|
639
|
+
_context5.next = 24;
|
|
444
640
|
break;
|
|
445
641
|
case 23:
|
|
446
|
-
|
|
642
|
+
_context5.t2 = null;
|
|
447
643
|
case 24:
|
|
448
|
-
|
|
644
|
+
_context5.t1 = _context5.t2;
|
|
449
645
|
case 25:
|
|
450
|
-
|
|
646
|
+
_context5.t0 = _context5.t1;
|
|
451
647
|
case 26:
|
|
452
|
-
localRecord =
|
|
648
|
+
localRecord = _context5.t0;
|
|
453
649
|
if (!localRecord) {
|
|
454
|
-
|
|
650
|
+
_context5.next = 35;
|
|
455
651
|
break;
|
|
456
652
|
}
|
|
457
|
-
|
|
653
|
+
_context5.next = 30;
|
|
458
654
|
return this.store.order.hydrateTempOrderFromRecord(localRecord, {
|
|
459
655
|
recalcOnHydrate: false
|
|
460
656
|
});
|
|
461
657
|
case 30:
|
|
462
|
-
_sales =
|
|
658
|
+
_sales = _context5.sent;
|
|
463
659
|
this.currentSalesDetail = _sales;
|
|
464
|
-
|
|
660
|
+
_context5.next = 34;
|
|
465
661
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
466
662
|
sales: _sales
|
|
467
663
|
});
|
|
468
664
|
case 34:
|
|
469
|
-
return
|
|
665
|
+
return _context5.abrupt("return", _sales);
|
|
470
666
|
case 35:
|
|
471
667
|
if (!(params.orderId === undefined || params.orderId === null)) {
|
|
472
|
-
|
|
668
|
+
_context5.next = 37;
|
|
473
669
|
break;
|
|
474
670
|
}
|
|
475
671
|
throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
|
|
476
672
|
case 37:
|
|
477
|
-
|
|
673
|
+
_context5.next = 39;
|
|
478
674
|
return this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
479
675
|
case 39:
|
|
480
|
-
res =
|
|
676
|
+
res = _context5.sent;
|
|
481
677
|
if (!(!res || res.code !== 200)) {
|
|
482
|
-
|
|
678
|
+
_context5.next = 43;
|
|
483
679
|
break;
|
|
484
680
|
}
|
|
485
681
|
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
|
|
486
682
|
throw new Error(message);
|
|
487
683
|
case 43:
|
|
488
|
-
|
|
684
|
+
_context5.next = 45;
|
|
489
685
|
return this.store.order.hydrateTempOrderFromRecord(res.data, {
|
|
490
686
|
recalcOnHydrate: false
|
|
491
687
|
});
|
|
492
688
|
case 45:
|
|
493
|
-
sales =
|
|
494
|
-
|
|
689
|
+
sales = _context5.sent;
|
|
690
|
+
_context5.next = 48;
|
|
495
691
|
return this.store.order.saveDraft();
|
|
496
692
|
case 48:
|
|
497
693
|
this.currentSalesDetail = sales;
|
|
498
|
-
|
|
694
|
+
_context5.next = 51;
|
|
499
695
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
500
696
|
sales: sales
|
|
501
697
|
});
|
|
502
698
|
case 51:
|
|
503
|
-
return
|
|
699
|
+
return _context5.abrupt("return", sales);
|
|
504
700
|
case 52:
|
|
505
701
|
case "end":
|
|
506
|
-
return
|
|
702
|
+
return _context5.stop();
|
|
507
703
|
}
|
|
508
|
-
},
|
|
704
|
+
}, _callee5, this);
|
|
509
705
|
}));
|
|
510
|
-
function loadSalesDetail(
|
|
706
|
+
function loadSalesDetail(_x5) {
|
|
511
707
|
return _loadSalesDetail.apply(this, arguments);
|
|
512
708
|
}
|
|
513
709
|
return loadSalesDetail;
|
|
@@ -587,34 +783,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
587
783
|
}, {
|
|
588
784
|
key: "replaceTempOrder",
|
|
589
785
|
value: function () {
|
|
590
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
786
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(tempOrder) {
|
|
591
787
|
var nextTempOrder;
|
|
592
|
-
return _regeneratorRuntime().wrap(function
|
|
593
|
-
while (1) switch (
|
|
788
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
789
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
594
790
|
case 0:
|
|
595
791
|
if (this.store.order) {
|
|
596
|
-
|
|
792
|
+
_context6.next = 2;
|
|
597
793
|
break;
|
|
598
794
|
}
|
|
599
795
|
throw new Error('order 模块未初始化');
|
|
600
796
|
case 2:
|
|
601
|
-
|
|
797
|
+
_context6.next = 4;
|
|
602
798
|
return this.store.order.replaceTempOrder(tempOrder);
|
|
603
799
|
case 4:
|
|
604
|
-
nextTempOrder =
|
|
605
|
-
|
|
800
|
+
nextTempOrder = _context6.sent;
|
|
801
|
+
_context6.next = 7;
|
|
606
802
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
607
803
|
tempOrder: nextTempOrder
|
|
608
804
|
});
|
|
609
805
|
case 7:
|
|
610
|
-
return
|
|
806
|
+
return _context6.abrupt("return", nextTempOrder);
|
|
611
807
|
case 8:
|
|
612
808
|
case "end":
|
|
613
|
-
return
|
|
809
|
+
return _context6.stop();
|
|
614
810
|
}
|
|
615
|
-
},
|
|
811
|
+
}, _callee6, this);
|
|
616
812
|
}));
|
|
617
|
-
function replaceTempOrder(
|
|
813
|
+
function replaceTempOrder(_x6) {
|
|
618
814
|
return _replaceTempOrder.apply(this, arguments);
|
|
619
815
|
}
|
|
620
816
|
return replaceTempOrder;
|
|
@@ -706,40 +902,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
706
902
|
}, {
|
|
707
903
|
key: "addNewOrder",
|
|
708
904
|
value: function () {
|
|
709
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
905
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
710
906
|
var tempOrder;
|
|
711
|
-
return _regeneratorRuntime().wrap(function
|
|
712
|
-
while (1) switch (
|
|
907
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
908
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
713
909
|
case 0:
|
|
714
|
-
|
|
910
|
+
_context7.prev = 0;
|
|
715
911
|
if (this.store.order) {
|
|
716
|
-
|
|
912
|
+
_context7.next = 3;
|
|
717
913
|
break;
|
|
718
914
|
}
|
|
719
915
|
throw new Error('order 模块未初始化');
|
|
720
916
|
case 3:
|
|
721
|
-
|
|
917
|
+
_context7.next = 5;
|
|
722
918
|
return this.store.order.addNewOrder();
|
|
723
919
|
case 5:
|
|
724
|
-
tempOrder =
|
|
920
|
+
tempOrder = _context7.sent;
|
|
725
921
|
if (!this.syncAppDataToTempOrder(tempOrder)) {
|
|
726
|
-
|
|
922
|
+
_context7.next = 10;
|
|
727
923
|
break;
|
|
728
924
|
}
|
|
729
925
|
this.store.order.persistTempOrder();
|
|
730
|
-
|
|
926
|
+
_context7.next = 10;
|
|
731
927
|
return this.store.order.saveDraft();
|
|
732
928
|
case 10:
|
|
733
|
-
return
|
|
929
|
+
return _context7.abrupt("return", tempOrder);
|
|
734
930
|
case 13:
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
throw
|
|
931
|
+
_context7.prev = 13;
|
|
932
|
+
_context7.t0 = _context7["catch"](0);
|
|
933
|
+
throw _context7.t0;
|
|
738
934
|
case 16:
|
|
739
935
|
case "end":
|
|
740
|
-
return
|
|
936
|
+
return _context7.stop();
|
|
741
937
|
}
|
|
742
|
-
},
|
|
938
|
+
}, _callee7, this, [[0, 13]]);
|
|
743
939
|
}));
|
|
744
940
|
function addNewOrder() {
|
|
745
941
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -749,22 +945,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
749
945
|
}, {
|
|
750
946
|
key: "saveDraft",
|
|
751
947
|
value: function () {
|
|
752
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
753
|
-
return _regeneratorRuntime().wrap(function
|
|
754
|
-
while (1) switch (
|
|
948
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
949
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
950
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
755
951
|
case 0:
|
|
756
952
|
if (this.store.order) {
|
|
757
|
-
|
|
953
|
+
_context8.next = 2;
|
|
758
954
|
break;
|
|
759
955
|
}
|
|
760
956
|
throw new Error('order 模块未初始化');
|
|
761
957
|
case 2:
|
|
762
|
-
return
|
|
958
|
+
return _context8.abrupt("return", this.store.order.saveDraft());
|
|
763
959
|
case 3:
|
|
764
960
|
case "end":
|
|
765
|
-
return
|
|
961
|
+
return _context8.stop();
|
|
766
962
|
}
|
|
767
|
-
},
|
|
963
|
+
}, _callee8, this);
|
|
768
964
|
}));
|
|
769
965
|
function saveDraft() {
|
|
770
966
|
return _saveDraft.apply(this, arguments);
|
|
@@ -775,14 +971,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
775
971
|
}, {
|
|
776
972
|
key: "restoreOrder",
|
|
777
973
|
value: function () {
|
|
778
|
-
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
974
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
779
975
|
var tempOrder;
|
|
780
|
-
return _regeneratorRuntime().wrap(function
|
|
781
|
-
while (1) switch (
|
|
976
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
977
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
782
978
|
case 0:
|
|
783
|
-
|
|
979
|
+
_context9.prev = 0;
|
|
784
980
|
if (this.store.order) {
|
|
785
|
-
|
|
981
|
+
_context9.next = 3;
|
|
786
982
|
break;
|
|
787
983
|
}
|
|
788
984
|
throw new Error('scanOrder 解决方案需要 order 模块支持');
|
|
@@ -792,29 +988,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
792
988
|
this.currentSalesDetail = null;
|
|
793
989
|
this.discountConfigCacheKey = null;
|
|
794
990
|
this.hasManualDiscountSelection = false;
|
|
795
|
-
|
|
991
|
+
_context9.next = 9;
|
|
796
992
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
797
993
|
tempOrder: tempOrder
|
|
798
994
|
});
|
|
799
995
|
case 9:
|
|
800
996
|
if (!this.syncAppDataToTempOrder(tempOrder)) {
|
|
801
|
-
|
|
997
|
+
_context9.next = 13;
|
|
802
998
|
break;
|
|
803
999
|
}
|
|
804
1000
|
this.store.order.persistTempOrder();
|
|
805
|
-
|
|
1001
|
+
_context9.next = 13;
|
|
806
1002
|
return this.store.order.saveDraft();
|
|
807
1003
|
case 13:
|
|
808
|
-
return
|
|
1004
|
+
return _context9.abrupt("return", tempOrder);
|
|
809
1005
|
case 16:
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
throw
|
|
1006
|
+
_context9.prev = 16;
|
|
1007
|
+
_context9.t0 = _context9["catch"](0);
|
|
1008
|
+
throw _context9.t0;
|
|
813
1009
|
case 19:
|
|
814
1010
|
case "end":
|
|
815
|
-
return
|
|
1011
|
+
return _context9.stop();
|
|
816
1012
|
}
|
|
817
|
-
},
|
|
1013
|
+
}, _callee9, this, [[0, 16]]);
|
|
818
1014
|
}));
|
|
819
1015
|
function restoreOrder() {
|
|
820
1016
|
return _restoreOrder.apply(this, arguments);
|
|
@@ -828,22 +1024,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
828
1024
|
}, {
|
|
829
1025
|
key: "clearOrderCartLines",
|
|
830
1026
|
value: (function () {
|
|
831
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1027
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
832
1028
|
var tempOrder;
|
|
833
|
-
return _regeneratorRuntime().wrap(function
|
|
834
|
-
while (1) switch (
|
|
1029
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1030
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
835
1031
|
case 0:
|
|
836
|
-
|
|
1032
|
+
_context10.prev = 0;
|
|
837
1033
|
if (this.store.order) {
|
|
838
|
-
|
|
1034
|
+
_context10.next = 3;
|
|
839
1035
|
break;
|
|
840
1036
|
}
|
|
841
1037
|
throw new Error('order 模块未初始化');
|
|
842
1038
|
case 3:
|
|
843
|
-
|
|
1039
|
+
_context10.next = 5;
|
|
844
1040
|
return this.store.order.clearOrderCartLines();
|
|
845
1041
|
case 5:
|
|
846
|
-
tempOrder =
|
|
1042
|
+
tempOrder = _context10.sent;
|
|
847
1043
|
if (this.currentSalesDetail) {
|
|
848
1044
|
this.currentSalesDetail = _objectSpread(_objectSpread({}, this.currentSalesDetail), {}, {
|
|
849
1045
|
products: [],
|
|
@@ -853,29 +1049,29 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
853
1049
|
discount_list: []
|
|
854
1050
|
});
|
|
855
1051
|
}
|
|
856
|
-
|
|
1052
|
+
_context10.next = 9;
|
|
857
1053
|
return this.effectsEmit('onTempOrderReplaced', {
|
|
858
1054
|
tempOrder: tempOrder
|
|
859
1055
|
});
|
|
860
1056
|
case 9:
|
|
861
1057
|
if (!this.syncAppDataToTempOrder(tempOrder)) {
|
|
862
|
-
|
|
1058
|
+
_context10.next = 13;
|
|
863
1059
|
break;
|
|
864
1060
|
}
|
|
865
1061
|
this.store.order.persistTempOrder();
|
|
866
|
-
|
|
1062
|
+
_context10.next = 13;
|
|
867
1063
|
return this.store.order.saveDraft();
|
|
868
1064
|
case 13:
|
|
869
|
-
return
|
|
1065
|
+
return _context10.abrupt("return", tempOrder);
|
|
870
1066
|
case 16:
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
throw
|
|
1067
|
+
_context10.prev = 16;
|
|
1068
|
+
_context10.t0 = _context10["catch"](0);
|
|
1069
|
+
throw _context10.t0;
|
|
874
1070
|
case 19:
|
|
875
1071
|
case "end":
|
|
876
|
-
return
|
|
1072
|
+
return _context10.stop();
|
|
877
1073
|
}
|
|
878
|
-
},
|
|
1074
|
+
}, _callee10, this, [[0, 16]]);
|
|
879
1075
|
}));
|
|
880
1076
|
function clearOrderCartLines() {
|
|
881
1077
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -892,32 +1088,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
892
1088
|
}, {
|
|
893
1089
|
key: "getSummary",
|
|
894
1090
|
value: function () {
|
|
895
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1091
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
896
1092
|
var summary;
|
|
897
|
-
return _regeneratorRuntime().wrap(function
|
|
898
|
-
while (1) switch (
|
|
1093
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1094
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
899
1095
|
case 0:
|
|
900
|
-
|
|
1096
|
+
_context11.prev = 0;
|
|
901
1097
|
if (this.store.order) {
|
|
902
|
-
|
|
1098
|
+
_context11.next = 3;
|
|
903
1099
|
break;
|
|
904
1100
|
}
|
|
905
1101
|
throw new Error('order 模块未初始化');
|
|
906
1102
|
case 3:
|
|
907
|
-
|
|
1103
|
+
_context11.next = 5;
|
|
908
1104
|
return this.store.order.getOrderSummary();
|
|
909
1105
|
case 5:
|
|
910
|
-
summary =
|
|
911
|
-
return
|
|
1106
|
+
summary = _context11.sent;
|
|
1107
|
+
return _context11.abrupt("return", summary);
|
|
912
1108
|
case 9:
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
throw
|
|
1109
|
+
_context11.prev = 9;
|
|
1110
|
+
_context11.t0 = _context11["catch"](0);
|
|
1111
|
+
throw _context11.t0;
|
|
916
1112
|
case 12:
|
|
917
1113
|
case "end":
|
|
918
|
-
return
|
|
1114
|
+
return _context11.stop();
|
|
919
1115
|
}
|
|
920
|
-
},
|
|
1116
|
+
}, _callee11, this, [[0, 9]]);
|
|
921
1117
|
}));
|
|
922
1118
|
function getSummary() {
|
|
923
1119
|
return _getSummary.apply(this, arguments);
|
|
@@ -927,10 +1123,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
927
1123
|
}, {
|
|
928
1124
|
key: "getHistoricalProductDiscountList",
|
|
929
1125
|
value: function getHistoricalProductDiscountList(products) {
|
|
930
|
-
var
|
|
1126
|
+
var _this5 = this;
|
|
931
1127
|
var historyDiscountList = [];
|
|
932
1128
|
products.forEach(function (item) {
|
|
933
|
-
if (!
|
|
1129
|
+
if (!_this5.isPersistedOrderProduct(item)) return;
|
|
934
1130
|
(item.discount_list || []).forEach(function (discount) {
|
|
935
1131
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
936
1132
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -1014,14 +1210,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1014
1210
|
}, {
|
|
1015
1211
|
key: "loadDiscountConfig",
|
|
1016
1212
|
value: function () {
|
|
1017
|
-
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1213
|
+
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
1018
1214
|
var _this$getOrderIdentit, _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2, _discountModule$getDi, _discountModule$getOr, _discountModule$getDi2;
|
|
1019
|
-
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$
|
|
1020
|
-
return _regeneratorRuntime().wrap(function
|
|
1021
|
-
while (1) switch (
|
|
1215
|
+
var tempOrder, orderStore, discountModule, rulesModule, orderId, customerId, currentDiscountList, originalDiscountList, hasManualDiscountSelection, discountAction, discountConfigCacheKey, preparedDiscountList, _discountModule$setOr, nextDiscountList, _tempOrder$holder, _tempOrder$holder2, _orderStore$summary, holders, result, _iterator, _step, _product$metadata2, _tempOrder$_extend3, _product$metadata3, _product$metadata$sou, _product$metadata4, _product$metadata5, _product$original_pri, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice, summary;
|
|
1216
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1217
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1022
1218
|
case 0:
|
|
1023
1219
|
if (this.store.order) {
|
|
1024
|
-
|
|
1220
|
+
_context12.next = 2;
|
|
1025
1221
|
break;
|
|
1026
1222
|
}
|
|
1027
1223
|
throw new Error('order 模块未初始化');
|
|
@@ -1041,18 +1237,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1041
1237
|
discountConfigCacheKey = [customerId, discountAction, Number(orderId) || 0].join(':');
|
|
1042
1238
|
preparedDiscountList = [];
|
|
1043
1239
|
if (!(customerId && customerId !== 1)) {
|
|
1044
|
-
|
|
1240
|
+
_context12.next = 25;
|
|
1045
1241
|
break;
|
|
1046
1242
|
}
|
|
1047
1243
|
if (!(this.discountConfigCacheKey === discountConfigCacheKey)) {
|
|
1048
|
-
|
|
1244
|
+
_context12.next = 19;
|
|
1049
1245
|
break;
|
|
1050
1246
|
}
|
|
1051
1247
|
preparedDiscountList = originalDiscountList;
|
|
1052
|
-
|
|
1248
|
+
_context12.next = 25;
|
|
1053
1249
|
break;
|
|
1054
1250
|
case 19:
|
|
1055
|
-
|
|
1251
|
+
_context12.next = 21;
|
|
1056
1252
|
return this.store.order.loadDiscountConfig({
|
|
1057
1253
|
customerId: customerId,
|
|
1058
1254
|
action: discountAction,
|
|
@@ -1060,27 +1256,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
1256
|
apply: false
|
|
1061
1257
|
});
|
|
1062
1258
|
case 21:
|
|
1063
|
-
preparedDiscountList =
|
|
1259
|
+
preparedDiscountList = _context12.sent;
|
|
1064
1260
|
this.discountConfigCacheKey = discountConfigCacheKey;
|
|
1065
|
-
|
|
1261
|
+
_context12.next = 25;
|
|
1066
1262
|
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, preparedDiscountList);
|
|
1067
1263
|
case 25:
|
|
1068
1264
|
if (!(hasManualDiscountSelection && currentDiscountList.length)) {
|
|
1069
|
-
|
|
1265
|
+
_context12.next = 27;
|
|
1070
1266
|
break;
|
|
1071
1267
|
}
|
|
1072
|
-
return
|
|
1268
|
+
return _context12.abrupt("return", {
|
|
1073
1269
|
productList: tempOrder.products || [],
|
|
1074
1270
|
discountList: currentDiscountList
|
|
1075
1271
|
});
|
|
1076
1272
|
case 27:
|
|
1077
1273
|
nextDiscountList = this.mergeHistoricalDiscountList(preparedDiscountList || (discountModule === null || discountModule === void 0 || (_discountModule$getDi2 = discountModule.getDiscountList) === null || _discountModule$getDi2 === void 0 ? void 0 : _discountModule$getDi2.call(discountModule)) || [], tempOrder.products || []);
|
|
1078
1274
|
nextDiscountList = this.mergeCurrentDiscountSelectionState(nextDiscountList, currentDiscountList);
|
|
1079
|
-
|
|
1275
|
+
_context12.next = 31;
|
|
1080
1276
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1081
1277
|
case 31:
|
|
1082
1278
|
if (!rulesModule) {
|
|
1083
|
-
|
|
1279
|
+
_context12.next = 67;
|
|
1084
1280
|
break;
|
|
1085
1281
|
}
|
|
1086
1282
|
holders = (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
@@ -1100,27 +1296,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1100
1296
|
tempOrder.products = result.productList;
|
|
1101
1297
|
}
|
|
1102
1298
|
_iterator = _createForOfIteratorHelper(tempOrder.products || []);
|
|
1103
|
-
|
|
1299
|
+
_context12.prev = 36;
|
|
1104
1300
|
_iterator.s();
|
|
1105
1301
|
case 38:
|
|
1106
1302
|
if ((_step = _iterator.n()).done) {
|
|
1107
|
-
|
|
1303
|
+
_context12.next = 53;
|
|
1108
1304
|
break;
|
|
1109
1305
|
}
|
|
1110
1306
|
product = _step.value;
|
|
1111
|
-
productUid = (_product$
|
|
1307
|
+
productUid = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number;
|
|
1112
1308
|
runtimeOrigin = productUid ? (_tempOrder$_extend3 = tempOrder._extend) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3.productsByUid) === null || _tempOrder$_extend3 === void 0 || (_tempOrder$_extend3 = _tempOrder$_extend3[productUid]) === null || _tempOrder$_extend3 === void 0 ? void 0 : _tempOrder$_extend3.origin : undefined;
|
|
1113
|
-
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$
|
|
1114
|
-
|
|
1309
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata3 = product.metadata) !== null && _product$metadata3 !== void 0 && _product$metadata3.is_manual_discount)) {
|
|
1310
|
+
_context12.next = 44;
|
|
1115
1311
|
break;
|
|
1116
1312
|
}
|
|
1117
|
-
return
|
|
1313
|
+
return _context12.abrupt("continue", 51);
|
|
1118
1314
|
case 44:
|
|
1119
1315
|
totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, pd) {
|
|
1120
1316
|
return sum + Number(pd.amount || 0);
|
|
1121
1317
|
}, 0);
|
|
1122
1318
|
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1123
|
-
sourcePrice = (_product$metadata$sou = (_product$
|
|
1319
|
+
sourcePrice = (_product$metadata$sou = (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : '0';
|
|
1124
1320
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1125
1321
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1126
1322
|
if (product.metadata) {
|
|
@@ -1132,41 +1328,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1132
1328
|
bundle: product.product_bundle
|
|
1133
1329
|
});
|
|
1134
1330
|
case 51:
|
|
1135
|
-
|
|
1331
|
+
_context12.next = 38;
|
|
1136
1332
|
break;
|
|
1137
1333
|
case 53:
|
|
1138
|
-
|
|
1334
|
+
_context12.next = 58;
|
|
1139
1335
|
break;
|
|
1140
1336
|
case 55:
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
_iterator.e(
|
|
1337
|
+
_context12.prev = 55;
|
|
1338
|
+
_context12.t0 = _context12["catch"](36);
|
|
1339
|
+
_iterator.e(_context12.t0);
|
|
1144
1340
|
case 58:
|
|
1145
|
-
|
|
1341
|
+
_context12.prev = 58;
|
|
1146
1342
|
_iterator.f();
|
|
1147
|
-
return
|
|
1343
|
+
return _context12.finish(58);
|
|
1148
1344
|
case 61:
|
|
1149
1345
|
if (!result.discountList) {
|
|
1150
|
-
|
|
1346
|
+
_context12.next = 67;
|
|
1151
1347
|
break;
|
|
1152
1348
|
}
|
|
1153
1349
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1154
1350
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1155
|
-
|
|
1351
|
+
_context12.next = 66;
|
|
1156
1352
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1157
1353
|
case 66:
|
|
1158
1354
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
1159
1355
|
return discount.isSelected;
|
|
1160
1356
|
});
|
|
1161
1357
|
case 67:
|
|
1162
|
-
|
|
1358
|
+
_context12.next = 69;
|
|
1163
1359
|
return this.store.order.recalculateSummary({
|
|
1164
1360
|
createIfMissing: true
|
|
1165
1361
|
});
|
|
1166
1362
|
case 69:
|
|
1167
|
-
summary =
|
|
1363
|
+
summary = _context12.sent;
|
|
1168
1364
|
this.store.order.persistTempOrder();
|
|
1169
|
-
|
|
1365
|
+
_context12.next = 73;
|
|
1170
1366
|
return this.effectsEmit('onDiscountApplied', {
|
|
1171
1367
|
productList: tempOrder.products || [],
|
|
1172
1368
|
discountList: nextDiscountList,
|
|
@@ -1174,17 +1370,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1174
1370
|
tempOrder: tempOrder
|
|
1175
1371
|
});
|
|
1176
1372
|
case 73:
|
|
1177
|
-
return
|
|
1373
|
+
return _context12.abrupt("return", {
|
|
1178
1374
|
productList: tempOrder.products || [],
|
|
1179
1375
|
discountList: nextDiscountList
|
|
1180
1376
|
});
|
|
1181
1377
|
case 74:
|
|
1182
1378
|
case "end":
|
|
1183
|
-
return
|
|
1379
|
+
return _context12.stop();
|
|
1184
1380
|
}
|
|
1185
|
-
},
|
|
1381
|
+
}, _callee12, this, [[36, 55, 58, 61]]);
|
|
1186
1382
|
}));
|
|
1187
|
-
function loadDiscountConfig(
|
|
1383
|
+
function loadDiscountConfig(_x7) {
|
|
1188
1384
|
return _loadDiscountConfig.apply(this, arguments);
|
|
1189
1385
|
}
|
|
1190
1386
|
return loadDiscountConfig;
|
|
@@ -1192,14 +1388,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1192
1388
|
}, {
|
|
1193
1389
|
key: "bestDiscount",
|
|
1194
1390
|
value: function () {
|
|
1195
|
-
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1391
|
+
var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(cb) {
|
|
1196
1392
|
var _discountModule$getOr2, _discountModule$getDi3;
|
|
1197
1393
|
var tempOrder, orderStore, discountModule, rulesModule, originalDiscountList, currentDiscountList, nextDiscountList, result, _tempOrder$holder3, _tempOrder$holder4, _orderStore$summary2, holders;
|
|
1198
|
-
return _regeneratorRuntime().wrap(function
|
|
1199
|
-
while (1) switch (
|
|
1394
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1395
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1200
1396
|
case 0:
|
|
1201
1397
|
if (this.store.order) {
|
|
1202
|
-
|
|
1398
|
+
_context13.next = 2;
|
|
1203
1399
|
break;
|
|
1204
1400
|
}
|
|
1205
1401
|
throw new Error('order 模块未初始化');
|
|
@@ -1215,11 +1411,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1215
1411
|
productList: tempOrder.products || [],
|
|
1216
1412
|
discountList: nextDiscountList
|
|
1217
1413
|
};
|
|
1218
|
-
|
|
1414
|
+
_context13.next = 12;
|
|
1219
1415
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1220
1416
|
case 12:
|
|
1221
1417
|
if (!rulesModule) {
|
|
1222
|
-
|
|
1418
|
+
_context13.next = 23;
|
|
1223
1419
|
break;
|
|
1224
1420
|
}
|
|
1225
1421
|
holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
@@ -1236,12 +1432,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1236
1432
|
tempOrder.products = result.productList;
|
|
1237
1433
|
}
|
|
1238
1434
|
if (!result.discountList) {
|
|
1239
|
-
|
|
1435
|
+
_context13.next = 23;
|
|
1240
1436
|
break;
|
|
1241
1437
|
}
|
|
1242
1438
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
1243
1439
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1244
|
-
|
|
1440
|
+
_context13.next = 21;
|
|
1245
1441
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1246
1442
|
case 21:
|
|
1247
1443
|
tempOrder.discount_list = nextDiscountList.filter(function (discount) {
|
|
@@ -1252,21 +1448,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1252
1448
|
discountList: nextDiscountList
|
|
1253
1449
|
};
|
|
1254
1450
|
case 23:
|
|
1255
|
-
|
|
1451
|
+
_context13.next = 25;
|
|
1256
1452
|
return this.store.order.recalculateSummary({
|
|
1257
1453
|
createIfMissing: true
|
|
1258
1454
|
});
|
|
1259
1455
|
case 25:
|
|
1260
1456
|
this.store.order.persistTempOrder();
|
|
1261
1457
|
cb === null || cb === void 0 || cb(result);
|
|
1262
|
-
return
|
|
1458
|
+
return _context13.abrupt("return", result);
|
|
1263
1459
|
case 28:
|
|
1264
1460
|
case "end":
|
|
1265
|
-
return
|
|
1461
|
+
return _context13.stop();
|
|
1266
1462
|
}
|
|
1267
|
-
},
|
|
1463
|
+
}, _callee13, this);
|
|
1268
1464
|
}));
|
|
1269
|
-
function bestDiscount(
|
|
1465
|
+
function bestDiscount(_x8) {
|
|
1270
1466
|
return _bestDiscount.apply(this, arguments);
|
|
1271
1467
|
}
|
|
1272
1468
|
return bestDiscount;
|
|
@@ -1280,49 +1476,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1280
1476
|
}, {
|
|
1281
1477
|
key: "scanPromotionCode",
|
|
1282
1478
|
value: function () {
|
|
1283
|
-
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1479
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(code, customerId) {
|
|
1284
1480
|
var raw;
|
|
1285
|
-
return _regeneratorRuntime().wrap(function
|
|
1286
|
-
while (1) switch (
|
|
1481
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1482
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1287
1483
|
case 0:
|
|
1288
|
-
|
|
1484
|
+
_context14.prev = 0;
|
|
1289
1485
|
if (this.store.order) {
|
|
1290
|
-
|
|
1486
|
+
_context14.next = 3;
|
|
1291
1487
|
break;
|
|
1292
1488
|
}
|
|
1293
1489
|
throw new Error('order 模块未初始化');
|
|
1294
1490
|
case 3:
|
|
1295
|
-
|
|
1491
|
+
_context14.next = 5;
|
|
1296
1492
|
return this.store.order.scanCode(code, customerId);
|
|
1297
1493
|
case 5:
|
|
1298
|
-
raw =
|
|
1494
|
+
raw = _context14.sent;
|
|
1299
1495
|
if (!raw.isAvailable) {
|
|
1300
|
-
|
|
1496
|
+
_context14.next = 10;
|
|
1301
1497
|
break;
|
|
1302
1498
|
}
|
|
1303
|
-
|
|
1499
|
+
_context14.next = 9;
|
|
1304
1500
|
return this.store.order.recalculateSummary({
|
|
1305
1501
|
createIfMissing: true
|
|
1306
1502
|
});
|
|
1307
1503
|
case 9:
|
|
1308
1504
|
this.store.order.persistTempOrder();
|
|
1309
1505
|
case 10:
|
|
1310
|
-
return
|
|
1506
|
+
return _context14.abrupt("return", {
|
|
1311
1507
|
isAvailable: raw.isAvailable,
|
|
1312
1508
|
type: raw.type,
|
|
1313
1509
|
unavailableReason: raw.unavailableReason
|
|
1314
1510
|
});
|
|
1315
1511
|
case 13:
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
throw
|
|
1512
|
+
_context14.prev = 13;
|
|
1513
|
+
_context14.t0 = _context14["catch"](0);
|
|
1514
|
+
throw _context14.t0;
|
|
1319
1515
|
case 16:
|
|
1320
1516
|
case "end":
|
|
1321
|
-
return
|
|
1517
|
+
return _context14.stop();
|
|
1322
1518
|
}
|
|
1323
|
-
},
|
|
1519
|
+
}, _callee14, this, [[0, 13]]);
|
|
1324
1520
|
}));
|
|
1325
|
-
function scanPromotionCode(
|
|
1521
|
+
function scanPromotionCode(_x9, _x10) {
|
|
1326
1522
|
return _scanPromotionCode.apply(this, arguments);
|
|
1327
1523
|
}
|
|
1328
1524
|
return scanPromotionCode;
|
|
@@ -1330,14 +1526,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1330
1526
|
}, {
|
|
1331
1527
|
key: "setDiscountSelected",
|
|
1332
1528
|
value: function () {
|
|
1333
|
-
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1334
|
-
var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$
|
|
1335
|
-
return _regeneratorRuntime().wrap(function
|
|
1336
|
-
while (1) switch (
|
|
1529
|
+
var _setDiscountSelected = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1530
|
+
var _tempOrder$holder5, list, updated, tempOrder, orderStore, discountModule, rulesModule, holders, nextDiscountList, _tempOrder$holder6, result, beforeSelectedIds, _iterator2, _step2, d, selectedResourceIds, _iterator3, _step3, _product$metadata6, _tempOrder$_extend4, _product$metadata7, _product$metadata$sou2, _product$metadata8, _product$metadata9, _product$original_pri2, product, productUid, runtimeOrigin, totalPerUnitDiscount, optionSum, sourcePrice, newSourceSellingPrice, newMainSellingPrice;
|
|
1531
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1532
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1337
1533
|
case 0:
|
|
1338
|
-
|
|
1534
|
+
_context15.prev = 0;
|
|
1339
1535
|
if (this.store.order) {
|
|
1340
|
-
|
|
1536
|
+
_context15.next = 3;
|
|
1341
1537
|
break;
|
|
1342
1538
|
}
|
|
1343
1539
|
throw new Error('order 模块未初始化');
|
|
@@ -1358,7 +1554,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1554
|
form_record_id: tempOrder.holder.form_record_id
|
|
1359
1555
|
}] : [];
|
|
1360
1556
|
nextDiscountList = updated;
|
|
1361
|
-
|
|
1557
|
+
_context15.next = 14;
|
|
1362
1558
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(updated);
|
|
1363
1559
|
case 14:
|
|
1364
1560
|
if (rulesModule) {
|
|
@@ -1408,21 +1604,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1408
1604
|
return d.id;
|
|
1409
1605
|
}));
|
|
1410
1606
|
_iterator3 = _createForOfIteratorHelper(tempOrder.products);
|
|
1411
|
-
|
|
1607
|
+
_context15.prev = 17;
|
|
1412
1608
|
_iterator3.s();
|
|
1413
1609
|
case 19:
|
|
1414
1610
|
if ((_step3 = _iterator3.n()).done) {
|
|
1415
|
-
|
|
1611
|
+
_context15.next = 35;
|
|
1416
1612
|
break;
|
|
1417
1613
|
}
|
|
1418
1614
|
product = _step3.value;
|
|
1419
|
-
productUid = (_product$
|
|
1615
|
+
productUid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
|
|
1420
1616
|
runtimeOrigin = productUid ? (_tempOrder$_extend4 = tempOrder._extend) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4.productsByUid) === null || _tempOrder$_extend4 === void 0 || (_tempOrder$_extend4 = _tempOrder$_extend4[productUid]) === null || _tempOrder$_extend4 === void 0 ? void 0 : _tempOrder$_extend4.origin : undefined;
|
|
1421
|
-
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$
|
|
1422
|
-
|
|
1617
|
+
if (!(runtimeOrigin !== null && runtimeOrigin !== void 0 && runtimeOrigin.isManualDiscount || (_product$metadata7 = product.metadata) !== null && _product$metadata7 !== void 0 && _product$metadata7.is_manual_discount)) {
|
|
1618
|
+
_context15.next = 25;
|
|
1423
1619
|
break;
|
|
1424
1620
|
}
|
|
1425
|
-
return
|
|
1621
|
+
return _context15.abrupt("continue", 33);
|
|
1426
1622
|
case 25:
|
|
1427
1623
|
product.discount_list = (product.discount_list || []).filter(function (pd) {
|
|
1428
1624
|
var _pd$discount$resource, _pd$discount;
|
|
@@ -1436,7 +1632,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1436
1632
|
return sum + (pd.amount || 0);
|
|
1437
1633
|
}, 0); // TODO 这块逻辑需要拿掉
|
|
1438
1634
|
optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
1439
|
-
sourcePrice = (_product$metadata$sou2 = (_product$
|
|
1635
|
+
sourcePrice = (_product$metadata$sou2 = (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.source_product_price) !== null && _product$metadata$sou2 !== void 0 ? _product$metadata$sou2 : ((_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
1440
1636
|
newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1441
1637
|
newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1442
1638
|
if (product.metadata) {
|
|
@@ -1448,28 +1644,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1448
1644
|
bundle: product.product_bundle
|
|
1449
1645
|
});
|
|
1450
1646
|
case 33:
|
|
1451
|
-
|
|
1647
|
+
_context15.next = 19;
|
|
1452
1648
|
break;
|
|
1453
1649
|
case 35:
|
|
1454
|
-
|
|
1650
|
+
_context15.next = 40;
|
|
1455
1651
|
break;
|
|
1456
1652
|
case 37:
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
_iterator3.e(
|
|
1653
|
+
_context15.prev = 37;
|
|
1654
|
+
_context15.t0 = _context15["catch"](17);
|
|
1655
|
+
_iterator3.e(_context15.t0);
|
|
1460
1656
|
case 40:
|
|
1461
|
-
|
|
1657
|
+
_context15.prev = 40;
|
|
1462
1658
|
_iterator3.f();
|
|
1463
|
-
return
|
|
1659
|
+
return _context15.finish(40);
|
|
1464
1660
|
case 43:
|
|
1465
1661
|
OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1466
|
-
|
|
1662
|
+
_context15.next = 46;
|
|
1467
1663
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(nextDiscountList);
|
|
1468
1664
|
case 46:
|
|
1469
1665
|
tempOrder.discount_list = (nextDiscountList || []).filter(function (d) {
|
|
1470
1666
|
return d.isSelected;
|
|
1471
1667
|
});
|
|
1472
|
-
|
|
1668
|
+
_context15.next = 49;
|
|
1473
1669
|
return this.store.order.recalculateSummary({
|
|
1474
1670
|
createIfMissing: true
|
|
1475
1671
|
});
|
|
@@ -1481,19 +1677,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1481
1677
|
selectedDiscountList: tempOrder.discount_list,
|
|
1482
1678
|
tempOrder: tempOrder
|
|
1483
1679
|
});
|
|
1484
|
-
|
|
1680
|
+
_context15.next = 56;
|
|
1485
1681
|
break;
|
|
1486
1682
|
case 53:
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
throw
|
|
1683
|
+
_context15.prev = 53;
|
|
1684
|
+
_context15.t1 = _context15["catch"](0);
|
|
1685
|
+
throw _context15.t1;
|
|
1490
1686
|
case 56:
|
|
1491
1687
|
case "end":
|
|
1492
|
-
return
|
|
1688
|
+
return _context15.stop();
|
|
1493
1689
|
}
|
|
1494
|
-
},
|
|
1690
|
+
}, _callee15, this, [[0, 53], [17, 37, 40, 43]]);
|
|
1495
1691
|
}));
|
|
1496
|
-
function setDiscountSelected(
|
|
1692
|
+
function setDiscountSelected(_x11) {
|
|
1497
1693
|
return _setDiscountSelected.apply(this, arguments);
|
|
1498
1694
|
}
|
|
1499
1695
|
return setDiscountSelected;
|
|
@@ -1501,23 +1697,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1501
1697
|
}, {
|
|
1502
1698
|
key: "applyDiscountCalculationResult",
|
|
1503
1699
|
value: function () {
|
|
1504
|
-
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1700
|
+
var _applyDiscountCalculationResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(result) {
|
|
1505
1701
|
var tempOrder, orderStore, discountModule;
|
|
1506
|
-
return _regeneratorRuntime().wrap(function
|
|
1507
|
-
while (1) switch (
|
|
1702
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1703
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1508
1704
|
case 0:
|
|
1509
|
-
|
|
1705
|
+
_context16.prev = 0;
|
|
1510
1706
|
if (this.store.order) {
|
|
1511
|
-
|
|
1707
|
+
_context16.next = 3;
|
|
1512
1708
|
break;
|
|
1513
1709
|
}
|
|
1514
1710
|
throw new Error('order 模块未初始化');
|
|
1515
1711
|
case 3:
|
|
1516
1712
|
if (result) {
|
|
1517
|
-
|
|
1713
|
+
_context16.next = 5;
|
|
1518
1714
|
break;
|
|
1519
1715
|
}
|
|
1520
|
-
return
|
|
1716
|
+
return _context16.abrupt("return");
|
|
1521
1717
|
case 5:
|
|
1522
1718
|
tempOrder = this.store.order.ensureTempOrder();
|
|
1523
1719
|
orderStore = this.store.order.store || {};
|
|
@@ -1526,36 +1722,36 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1526
1722
|
tempOrder.products = result.productList;
|
|
1527
1723
|
}
|
|
1528
1724
|
if (!result.discountList) {
|
|
1529
|
-
|
|
1725
|
+
_context16.next = 14;
|
|
1530
1726
|
break;
|
|
1531
1727
|
}
|
|
1532
1728
|
OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
1533
|
-
|
|
1729
|
+
_context16.next = 13;
|
|
1534
1730
|
return discountModule === null || discountModule === void 0 ? void 0 : discountModule.setDiscountList(result.discountList);
|
|
1535
1731
|
case 13:
|
|
1536
1732
|
tempOrder.discount_list = result.discountList.filter(function (discount) {
|
|
1537
1733
|
return discount.isSelected;
|
|
1538
1734
|
});
|
|
1539
1735
|
case 14:
|
|
1540
|
-
|
|
1736
|
+
_context16.next = 16;
|
|
1541
1737
|
return this.store.order.recalculateSummary({
|
|
1542
1738
|
createIfMissing: true
|
|
1543
1739
|
});
|
|
1544
1740
|
case 16:
|
|
1545
1741
|
this.store.order.persistTempOrder();
|
|
1546
|
-
|
|
1742
|
+
_context16.next = 22;
|
|
1547
1743
|
break;
|
|
1548
1744
|
case 19:
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
throw
|
|
1745
|
+
_context16.prev = 19;
|
|
1746
|
+
_context16.t0 = _context16["catch"](0);
|
|
1747
|
+
throw _context16.t0;
|
|
1552
1748
|
case 22:
|
|
1553
1749
|
case "end":
|
|
1554
|
-
return
|
|
1750
|
+
return _context16.stop();
|
|
1555
1751
|
}
|
|
1556
|
-
},
|
|
1752
|
+
}, _callee16, this, [[0, 19]]);
|
|
1557
1753
|
}));
|
|
1558
|
-
function applyDiscountCalculationResult(
|
|
1754
|
+
function applyDiscountCalculationResult(_x12) {
|
|
1559
1755
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
1560
1756
|
}
|
|
1561
1757
|
return applyDiscountCalculationResult;
|
|
@@ -1563,18 +1759,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1563
1759
|
}, {
|
|
1564
1760
|
key: "submitScanOrder",
|
|
1565
1761
|
value: function () {
|
|
1566
|
-
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1567
|
-
return _regeneratorRuntime().wrap(function
|
|
1568
|
-
while (1) switch (
|
|
1762
|
+
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1763
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1764
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1569
1765
|
case 0:
|
|
1570
|
-
return
|
|
1766
|
+
return _context17.abrupt("return", this.submitSalesOrder(params));
|
|
1571
1767
|
case 1:
|
|
1572
1768
|
case "end":
|
|
1573
|
-
return
|
|
1769
|
+
return _context17.stop();
|
|
1574
1770
|
}
|
|
1575
|
-
},
|
|
1771
|
+
}, _callee17, this);
|
|
1576
1772
|
}));
|
|
1577
|
-
function submitScanOrder(
|
|
1773
|
+
function submitScanOrder(_x13) {
|
|
1578
1774
|
return _submitScanOrder.apply(this, arguments);
|
|
1579
1775
|
}
|
|
1580
1776
|
return submitScanOrder;
|
|
@@ -1588,14 +1784,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1588
1784
|
}, {
|
|
1589
1785
|
key: "submitSalesOrder",
|
|
1590
1786
|
value: (function () {
|
|
1591
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1592
|
-
var _this$
|
|
1787
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
1788
|
+
var _this$otherParams5, _this$otherParams6, _this$otherParams7;
|
|
1593
1789
|
var submitParams;
|
|
1594
|
-
return _regeneratorRuntime().wrap(function
|
|
1595
|
-
while (1) switch (
|
|
1790
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1791
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1596
1792
|
case 0:
|
|
1597
1793
|
if (this.store.order) {
|
|
1598
|
-
|
|
1794
|
+
_context18.next = 2;
|
|
1599
1795
|
break;
|
|
1600
1796
|
}
|
|
1601
1797
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -1603,10 +1799,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1603
1799
|
this.store.order.persistTempOrder();
|
|
1604
1800
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
1605
1801
|
cacheId: this.cacheId,
|
|
1606
|
-
platform: (_this$
|
|
1607
|
-
businessCode: (_this$
|
|
1802
|
+
platform: (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform,
|
|
1803
|
+
businessCode: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode,
|
|
1608
1804
|
channel: this.getSubmitOrderSalesChannel(),
|
|
1609
|
-
type: (_this$
|
|
1805
|
+
type: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.type
|
|
1610
1806
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
1611
1807
|
payments: params.payments
|
|
1612
1808
|
} : {}), (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined ? {
|
|
@@ -1617,14 +1813,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1617
1813
|
enhancePayload: params.enhancePayload
|
|
1618
1814
|
} : {});
|
|
1619
1815
|
console.log(submitParams, 'submitParams123');
|
|
1620
|
-
return
|
|
1816
|
+
return _context18.abrupt("return", this.store.order.submitTempOrder(submitParams));
|
|
1621
1817
|
case 6:
|
|
1622
1818
|
case "end":
|
|
1623
|
-
return
|
|
1819
|
+
return _context18.stop();
|
|
1624
1820
|
}
|
|
1625
|
-
},
|
|
1821
|
+
}, _callee18, this);
|
|
1626
1822
|
}));
|
|
1627
|
-
function submitSalesOrder(
|
|
1823
|
+
function submitSalesOrder(_x14) {
|
|
1628
1824
|
return _submitSalesOrder.apply(this, arguments);
|
|
1629
1825
|
}
|
|
1630
1826
|
return submitSalesOrder;
|
|
@@ -1632,14 +1828,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
1828
|
}, {
|
|
1633
1829
|
key: "syncPaymentsToOrder",
|
|
1634
1830
|
value: function () {
|
|
1635
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1831
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1636
1832
|
var _params$channel;
|
|
1637
1833
|
var channel, syncParams, syncState, payments, syncResult;
|
|
1638
|
-
return _regeneratorRuntime().wrap(function
|
|
1639
|
-
while (1) switch (
|
|
1834
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1835
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1640
1836
|
case 0:
|
|
1641
1837
|
if (this.store.order) {
|
|
1642
|
-
|
|
1838
|
+
_context19.next = 2;
|
|
1643
1839
|
break;
|
|
1644
1840
|
}
|
|
1645
1841
|
throw new Error('order 模块未初始化');
|
|
@@ -1650,13 +1846,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1650
1846
|
} : {});
|
|
1651
1847
|
syncState = this.store.order.getOrderSyncState();
|
|
1652
1848
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
1653
|
-
|
|
1849
|
+
_context19.next = 7;
|
|
1654
1850
|
break;
|
|
1655
1851
|
}
|
|
1656
|
-
return
|
|
1852
|
+
return _context19.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
1657
1853
|
case 7:
|
|
1658
1854
|
payments = params.payments || [];
|
|
1659
|
-
|
|
1855
|
+
_context19.next = 10;
|
|
1660
1856
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
1661
1857
|
payments: payments,
|
|
1662
1858
|
params: syncParams,
|
|
@@ -1664,12 +1860,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1664
1860
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1665
1861
|
});
|
|
1666
1862
|
case 10:
|
|
1667
|
-
|
|
1668
|
-
|
|
1863
|
+
_context19.prev = 10;
|
|
1864
|
+
_context19.next = 13;
|
|
1669
1865
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
1670
1866
|
case 13:
|
|
1671
|
-
syncResult =
|
|
1672
|
-
|
|
1867
|
+
syncResult = _context19.sent;
|
|
1868
|
+
_context19.next = 16;
|
|
1673
1869
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1674
1870
|
ok: true,
|
|
1675
1871
|
syncResult: syncResult,
|
|
@@ -1679,28 +1875,28 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1679
1875
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1680
1876
|
});
|
|
1681
1877
|
case 16:
|
|
1682
|
-
return
|
|
1878
|
+
return _context19.abrupt("return", syncResult);
|
|
1683
1879
|
case 19:
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1880
|
+
_context19.prev = 19;
|
|
1881
|
+
_context19.t0 = _context19["catch"](10);
|
|
1882
|
+
_context19.next = 23;
|
|
1687
1883
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
1688
1884
|
ok: false,
|
|
1689
|
-
error:
|
|
1885
|
+
error: _context19.t0,
|
|
1690
1886
|
payments: this.store.order.getOrderPayments(),
|
|
1691
1887
|
params: syncParams,
|
|
1692
1888
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
1693
1889
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
1694
1890
|
});
|
|
1695
1891
|
case 23:
|
|
1696
|
-
throw
|
|
1892
|
+
throw _context19.t0;
|
|
1697
1893
|
case 24:
|
|
1698
1894
|
case "end":
|
|
1699
|
-
return
|
|
1895
|
+
return _context19.stop();
|
|
1700
1896
|
}
|
|
1701
|
-
},
|
|
1897
|
+
}, _callee19, this, [[10, 19]]);
|
|
1702
1898
|
}));
|
|
1703
|
-
function syncPaymentsToOrder(
|
|
1899
|
+
function syncPaymentsToOrder(_x15) {
|
|
1704
1900
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
1705
1901
|
}
|
|
1706
1902
|
return syncPaymentsToOrder;
|
|
@@ -1724,9 +1920,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1724
1920
|
}, {
|
|
1725
1921
|
key: "addOrderPayment",
|
|
1726
1922
|
value: function addOrderPayment(payment) {
|
|
1727
|
-
var
|
|
1923
|
+
var _this6 = this;
|
|
1728
1924
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1729
|
-
var
|
|
1925
|
+
var paymentRecord = payment;
|
|
1926
|
+
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1927
|
+
if (!metadata.unique_identification_number) {
|
|
1928
|
+
metadata.unique_identification_number = createUuidV4();
|
|
1929
|
+
}
|
|
1930
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1931
|
+
metadata: metadata
|
|
1932
|
+
}));
|
|
1730
1933
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
1731
1934
|
var syncState = this.store.order.getOrderSyncState();
|
|
1732
1935
|
if (amountSnapshot && syncState !== 'submitting') {
|
|
@@ -1737,7 +1940,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1737
1940
|
submitWhenPaid: true,
|
|
1738
1941
|
smallTicketDataFlag: 1
|
|
1739
1942
|
}).catch(function (error) {
|
|
1740
|
-
|
|
1943
|
+
_this6.logError('auto sync payments failed', {
|
|
1741
1944
|
error: error instanceof Error ? error.message : String(error)
|
|
1742
1945
|
});
|
|
1743
1946
|
});
|
|
@@ -1779,11 +1982,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1779
1982
|
return n.product_id;
|
|
1780
1983
|
});
|
|
1781
1984
|
return products.map(function (product) {
|
|
1782
|
-
var _product$
|
|
1985
|
+
var _product$product_vari2, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
|
|
1783
1986
|
var metadata = product.metadata || {};
|
|
1784
1987
|
return {
|
|
1785
1988
|
product_id: product.product_id,
|
|
1786
|
-
product_variant_id: String((_product$
|
|
1989
|
+
product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
|
|
1787
1990
|
quantity: product.num || 1,
|
|
1788
1991
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1789
1992
|
is_charge_tax: (_product$is_charge_ta = product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
@@ -1800,14 +2003,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1800
2003
|
surcharge_rounding_remainder: metadata.surcharge_rounding_remainder
|
|
1801
2004
|
},
|
|
1802
2005
|
product_bundle: (product.product_bundle || []).map(function (bundle) {
|
|
1803
|
-
var _bundle$
|
|
2006
|
+
var _bundle$bundle_id2, _bundle$bundle_produc2, _bundle$bundle_group_2;
|
|
1804
2007
|
var bundleMetadata = bundle.metadata || {};
|
|
1805
2008
|
return {
|
|
1806
2009
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
1807
2010
|
// 套餐子项在 tempOrder 上常为 id(如 1718),prepare/deduction 协议要求 bundle_id
|
|
1808
|
-
bundle_id: (_bundle$
|
|
1809
|
-
bundle_product_id: (_bundle$
|
|
1810
|
-
bundle_group_id: (_bundle$
|
|
2011
|
+
bundle_id: (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id,
|
|
2012
|
+
bundle_product_id: (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id,
|
|
2013
|
+
bundle_group_id: (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id,
|
|
1811
2014
|
bundle_variant_id: bundle.bundle_variant_id,
|
|
1812
2015
|
price_type: bundle.price_type,
|
|
1813
2016
|
price_type_ext: bundle.price_type_ext,
|
|
@@ -1828,20 +2031,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1828
2031
|
}, {
|
|
1829
2032
|
key: "initWalletData",
|
|
1830
2033
|
value: function () {
|
|
1831
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1832
|
-
var _params$order_wait_pa,
|
|
2034
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
2035
|
+
var _params$order_wait_pa, _ref9, _tempOrder$is_price_i;
|
|
1833
2036
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
1834
|
-
return _regeneratorRuntime().wrap(function
|
|
1835
|
-
while (1) switch (
|
|
2037
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2038
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1836
2039
|
case 0:
|
|
1837
2040
|
if (this.store.order) {
|
|
1838
|
-
|
|
2041
|
+
_context20.next = 2;
|
|
1839
2042
|
break;
|
|
1840
2043
|
}
|
|
1841
2044
|
throw new Error('order 模块未初始化');
|
|
1842
2045
|
case 2:
|
|
1843
2046
|
if (this.store.payment) {
|
|
1844
|
-
|
|
2047
|
+
_context20.next = 4;
|
|
1845
2048
|
break;
|
|
1846
2049
|
}
|
|
1847
2050
|
throw new Error('payment 模块未初始化');
|
|
@@ -1850,10 +2053,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1850
2053
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
1851
2054
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
1852
2055
|
if (!(!tempOrder || !amount)) {
|
|
1853
|
-
|
|
2056
|
+
_context20.next = 9;
|
|
1854
2057
|
break;
|
|
1855
2058
|
}
|
|
1856
|
-
return
|
|
2059
|
+
return _context20.abrupt("return", {
|
|
1857
2060
|
walletRecommendList: [],
|
|
1858
2061
|
userIdentificationCodes: [],
|
|
1859
2062
|
transformList: [],
|
|
@@ -1872,15 +2075,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1872
2075
|
},
|
|
1873
2076
|
products: this.getWalletProductList(),
|
|
1874
2077
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
1875
|
-
is_price_include_tax: (
|
|
2078
|
+
is_price_include_tax: (_ref9 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref9 !== void 0 ? _ref9 : 1
|
|
1876
2079
|
}, snapshot.identity.orderId ? {
|
|
1877
2080
|
payment_order_id: String(snapshot.identity.orderId)
|
|
1878
2081
|
} : {});
|
|
1879
|
-
|
|
2082
|
+
_context20.next = 12;
|
|
1880
2083
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
1881
2084
|
case 12:
|
|
1882
|
-
result =
|
|
1883
|
-
|
|
2085
|
+
result = _context20.sent;
|
|
2086
|
+
_context20.next = 15;
|
|
1884
2087
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
1885
2088
|
orderId: snapshot.identity.orderId,
|
|
1886
2089
|
customerId: walletBusinessData.customer_id,
|
|
@@ -1892,14 +2095,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1892
2095
|
timestamp: Date.now()
|
|
1893
2096
|
});
|
|
1894
2097
|
case 15:
|
|
1895
|
-
return
|
|
2098
|
+
return _context20.abrupt("return", result);
|
|
1896
2099
|
case 16:
|
|
1897
2100
|
case "end":
|
|
1898
|
-
return
|
|
2101
|
+
return _context20.stop();
|
|
1899
2102
|
}
|
|
1900
|
-
},
|
|
2103
|
+
}, _callee20, this);
|
|
1901
2104
|
}));
|
|
1902
|
-
function initWalletData(
|
|
2105
|
+
function initWalletData(_x16) {
|
|
1903
2106
|
return _initWalletData.apply(this, arguments);
|
|
1904
2107
|
}
|
|
1905
2108
|
return initWalletData;
|
|
@@ -1926,27 +2129,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1926
2129
|
}, {
|
|
1927
2130
|
key: "getPaymentMethodsAsync",
|
|
1928
2131
|
value: (function () {
|
|
1929
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2132
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1930
2133
|
var response;
|
|
1931
|
-
return _regeneratorRuntime().wrap(function
|
|
1932
|
-
while (1) switch (
|
|
2134
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2135
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1933
2136
|
case 0:
|
|
1934
2137
|
if (!this.store.payment) {
|
|
1935
|
-
|
|
2138
|
+
_context21.next = 2;
|
|
1936
2139
|
break;
|
|
1937
2140
|
}
|
|
1938
|
-
return
|
|
2141
|
+
return _context21.abrupt("return", this.store.payment.getPayMethodListAsync());
|
|
1939
2142
|
case 2:
|
|
1940
|
-
|
|
2143
|
+
_context21.next = 4;
|
|
1941
2144
|
return this.request.get('/pay/custom-payment/all');
|
|
1942
2145
|
case 4:
|
|
1943
|
-
response =
|
|
1944
|
-
return
|
|
2146
|
+
response = _context21.sent;
|
|
2147
|
+
return _context21.abrupt("return", (response === null || response === void 0 ? void 0 : response.data) || []);
|
|
1945
2148
|
case 6:
|
|
1946
2149
|
case "end":
|
|
1947
|
-
return
|
|
2150
|
+
return _context21.stop();
|
|
1948
2151
|
}
|
|
1949
|
-
},
|
|
2152
|
+
}, _callee21, this);
|
|
1950
2153
|
}));
|
|
1951
2154
|
function getPaymentMethodsAsync() {
|
|
1952
2155
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1987,49 +2190,49 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1987
2190
|
}, {
|
|
1988
2191
|
key: "sendCustomerPayLink",
|
|
1989
2192
|
value: (function () {
|
|
1990
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1991
|
-
var orderIds,
|
|
1992
|
-
return _regeneratorRuntime().wrap(function
|
|
1993
|
-
while (1) switch (
|
|
2193
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2194
|
+
var orderIds, _ref10, _ref11, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
2195
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2196
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1994
2197
|
case 0:
|
|
1995
2198
|
if (this.store.order) {
|
|
1996
|
-
|
|
2199
|
+
_context22.next = 2;
|
|
1997
2200
|
break;
|
|
1998
2201
|
}
|
|
1999
2202
|
throw new Error('order 模块未初始化');
|
|
2000
2203
|
case 2:
|
|
2001
2204
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2002
2205
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
2003
|
-
|
|
2206
|
+
_context22.next = 11;
|
|
2004
2207
|
break;
|
|
2005
2208
|
}
|
|
2006
|
-
|
|
2209
|
+
_context22.next = 6;
|
|
2007
2210
|
return this.submitSalesOrder({
|
|
2008
2211
|
smallTicketDataFlag: 1
|
|
2009
2212
|
});
|
|
2010
2213
|
case 6:
|
|
2011
|
-
submitResult =
|
|
2012
|
-
orderId = (
|
|
2214
|
+
submitResult = _context22.sent;
|
|
2215
|
+
orderId = (_ref10 = (_ref11 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref11 !== void 0 ? _ref11 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref10 !== void 0 ? _ref10 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
2013
2216
|
if (orderId) {
|
|
2014
|
-
|
|
2217
|
+
_context22.next = 10;
|
|
2015
2218
|
break;
|
|
2016
2219
|
}
|
|
2017
2220
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
2018
2221
|
case 10:
|
|
2019
2222
|
orderIds = [orderId];
|
|
2020
2223
|
case 11:
|
|
2021
|
-
return
|
|
2224
|
+
return _context22.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
2022
2225
|
emails: params.emails,
|
|
2023
2226
|
notify_action: params.notify_action,
|
|
2024
2227
|
order_ids: orderIds
|
|
2025
2228
|
}));
|
|
2026
2229
|
case 12:
|
|
2027
2230
|
case "end":
|
|
2028
|
-
return
|
|
2231
|
+
return _context22.stop();
|
|
2029
2232
|
}
|
|
2030
|
-
},
|
|
2233
|
+
}, _callee22, this);
|
|
2031
2234
|
}));
|
|
2032
|
-
function sendCustomerPayLink(
|
|
2235
|
+
function sendCustomerPayLink(_x17) {
|
|
2033
2236
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
2034
2237
|
}
|
|
2035
2238
|
return sendCustomerPayLink;
|
|
@@ -2042,32 +2245,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2042
2245
|
}, {
|
|
2043
2246
|
key: "calculateProductBookingPrice",
|
|
2044
2247
|
value: function () {
|
|
2045
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2248
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
2046
2249
|
var _params$customer_id;
|
|
2047
|
-
var quotation, customerId;
|
|
2048
|
-
return _regeneratorRuntime().wrap(function
|
|
2049
|
-
while (1) switch (
|
|
2250
|
+
var quotation, customerId, authoritativeProduct, product;
|
|
2251
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2252
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2050
2253
|
case 0:
|
|
2051
2254
|
quotation = this.store.quotation;
|
|
2052
2255
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
2053
|
-
|
|
2256
|
+
_context23.next = 4;
|
|
2257
|
+
return this.loadProductForPriceQuery(params, customerId);
|
|
2258
|
+
case 4:
|
|
2259
|
+
authoritativeProduct = _context23.sent;
|
|
2260
|
+
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
2261
|
+
_context23.next = 8;
|
|
2054
2262
|
return this.loadQuotationForPriceQuery({
|
|
2055
2263
|
quotation: quotation,
|
|
2056
2264
|
customer_id: customerId,
|
|
2057
2265
|
channel: params.channel
|
|
2058
2266
|
});
|
|
2059
|
-
case
|
|
2060
|
-
return
|
|
2267
|
+
case 8:
|
|
2268
|
+
return _context23.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
2269
|
+
product: product,
|
|
2270
|
+
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
2061
2271
|
customer_id: customerId,
|
|
2062
2272
|
quotation: quotation
|
|
2063
2273
|
})));
|
|
2064
|
-
case
|
|
2274
|
+
case 9:
|
|
2065
2275
|
case "end":
|
|
2066
|
-
return
|
|
2276
|
+
return _context23.stop();
|
|
2067
2277
|
}
|
|
2068
|
-
},
|
|
2278
|
+
}, _callee23, this);
|
|
2069
2279
|
}));
|
|
2070
|
-
function calculateProductBookingPrice(
|
|
2280
|
+
function calculateProductBookingPrice(_x18) {
|
|
2071
2281
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
2072
2282
|
}
|
|
2073
2283
|
return calculateProductBookingPrice;
|
|
@@ -2075,34 +2285,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2075
2285
|
}, {
|
|
2076
2286
|
key: "addProductToOrder",
|
|
2077
2287
|
value: function () {
|
|
2078
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2288
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(product, booking) {
|
|
2079
2289
|
var products;
|
|
2080
|
-
return _regeneratorRuntime().wrap(function
|
|
2081
|
-
while (1) switch (
|
|
2290
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2291
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2082
2292
|
case 0:
|
|
2083
|
-
|
|
2293
|
+
_context24.prev = 0;
|
|
2084
2294
|
if (this.store.order) {
|
|
2085
|
-
|
|
2295
|
+
_context24.next = 3;
|
|
2086
2296
|
break;
|
|
2087
2297
|
}
|
|
2088
2298
|
throw new Error('order 模块未初始化');
|
|
2089
2299
|
case 3:
|
|
2090
|
-
|
|
2300
|
+
_context24.next = 5;
|
|
2091
2301
|
return this.store.order.addProductToOrder(product, booking);
|
|
2092
2302
|
case 5:
|
|
2093
|
-
products =
|
|
2094
|
-
return
|
|
2303
|
+
products = _context24.sent;
|
|
2304
|
+
return _context24.abrupt("return", products);
|
|
2095
2305
|
case 9:
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
throw
|
|
2306
|
+
_context24.prev = 9;
|
|
2307
|
+
_context24.t0 = _context24["catch"](0);
|
|
2308
|
+
throw _context24.t0;
|
|
2099
2309
|
case 12:
|
|
2100
2310
|
case "end":
|
|
2101
|
-
return
|
|
2311
|
+
return _context24.stop();
|
|
2102
2312
|
}
|
|
2103
|
-
},
|
|
2313
|
+
}, _callee24, this, [[0, 9]]);
|
|
2104
2314
|
}));
|
|
2105
|
-
function addProductToOrder(
|
|
2315
|
+
function addProductToOrder(_x19, _x20) {
|
|
2106
2316
|
return _addProductToOrder.apply(this, arguments);
|
|
2107
2317
|
}
|
|
2108
2318
|
return addProductToOrder;
|
|
@@ -2110,34 +2320,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2110
2320
|
}, {
|
|
2111
2321
|
key: "updateOrderProduct",
|
|
2112
2322
|
value: function () {
|
|
2113
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2323
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2114
2324
|
var products;
|
|
2115
|
-
return _regeneratorRuntime().wrap(function
|
|
2116
|
-
while (1) switch (
|
|
2325
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2326
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2117
2327
|
case 0:
|
|
2118
|
-
|
|
2328
|
+
_context25.prev = 0;
|
|
2119
2329
|
if (this.store.order) {
|
|
2120
|
-
|
|
2330
|
+
_context25.next = 3;
|
|
2121
2331
|
break;
|
|
2122
2332
|
}
|
|
2123
2333
|
throw new Error('order 模块未初始化');
|
|
2124
2334
|
case 3:
|
|
2125
|
-
|
|
2335
|
+
_context25.next = 5;
|
|
2126
2336
|
return this.store.order.updateOrderProduct(params);
|
|
2127
2337
|
case 5:
|
|
2128
|
-
products =
|
|
2129
|
-
return
|
|
2338
|
+
products = _context25.sent;
|
|
2339
|
+
return _context25.abrupt("return", products);
|
|
2130
2340
|
case 9:
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
throw
|
|
2341
|
+
_context25.prev = 9;
|
|
2342
|
+
_context25.t0 = _context25["catch"](0);
|
|
2343
|
+
throw _context25.t0;
|
|
2134
2344
|
case 12:
|
|
2135
2345
|
case "end":
|
|
2136
|
-
return
|
|
2346
|
+
return _context25.stop();
|
|
2137
2347
|
}
|
|
2138
|
-
},
|
|
2348
|
+
}, _callee25, this, [[0, 9]]);
|
|
2139
2349
|
}));
|
|
2140
|
-
function updateOrderProduct(
|
|
2350
|
+
function updateOrderProduct(_x21) {
|
|
2141
2351
|
return _updateOrderProduct.apply(this, arguments);
|
|
2142
2352
|
}
|
|
2143
2353
|
return updateOrderProduct;
|
|
@@ -2145,34 +2355,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2145
2355
|
}, {
|
|
2146
2356
|
key: "updateOrderProductQuantity",
|
|
2147
2357
|
value: function () {
|
|
2148
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2358
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2149
2359
|
var products;
|
|
2150
|
-
return _regeneratorRuntime().wrap(function
|
|
2151
|
-
while (1) switch (
|
|
2360
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2361
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2152
2362
|
case 0:
|
|
2153
|
-
|
|
2363
|
+
_context26.prev = 0;
|
|
2154
2364
|
if (this.store.order) {
|
|
2155
|
-
|
|
2365
|
+
_context26.next = 3;
|
|
2156
2366
|
break;
|
|
2157
2367
|
}
|
|
2158
2368
|
throw new Error('order 模块未初始化');
|
|
2159
2369
|
case 3:
|
|
2160
|
-
|
|
2370
|
+
_context26.next = 5;
|
|
2161
2371
|
return this.store.order.updateOrderProductQuantity(params);
|
|
2162
2372
|
case 5:
|
|
2163
|
-
products =
|
|
2164
|
-
return
|
|
2373
|
+
products = _context26.sent;
|
|
2374
|
+
return _context26.abrupt("return", products);
|
|
2165
2375
|
case 9:
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
throw
|
|
2376
|
+
_context26.prev = 9;
|
|
2377
|
+
_context26.t0 = _context26["catch"](0);
|
|
2378
|
+
throw _context26.t0;
|
|
2169
2379
|
case 12:
|
|
2170
2380
|
case "end":
|
|
2171
|
-
return
|
|
2381
|
+
return _context26.stop();
|
|
2172
2382
|
}
|
|
2173
|
-
},
|
|
2383
|
+
}, _callee26, this, [[0, 9]]);
|
|
2174
2384
|
}));
|
|
2175
|
-
function updateOrderProductQuantity(
|
|
2385
|
+
function updateOrderProductQuantity(_x22) {
|
|
2176
2386
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
2177
2387
|
}
|
|
2178
2388
|
return updateOrderProductQuantity;
|
|
@@ -2195,12 +2405,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2195
2405
|
}, {
|
|
2196
2406
|
key: "setOrderProductLineNote",
|
|
2197
2407
|
value: (function () {
|
|
2198
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2408
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identity, note) {
|
|
2199
2409
|
var params, products;
|
|
2200
|
-
return _regeneratorRuntime().wrap(function
|
|
2201
|
-
while (1) switch (
|
|
2410
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2411
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2202
2412
|
case 0:
|
|
2203
|
-
|
|
2413
|
+
_context27.prev = 0;
|
|
2204
2414
|
params = {
|
|
2205
2415
|
product_id: identity.product_id,
|
|
2206
2416
|
product_variant_id: identity.product_variant_id,
|
|
@@ -2215,22 +2425,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2215
2425
|
params.product_option_item = identity.product_option_item;
|
|
2216
2426
|
}
|
|
2217
2427
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
2218
|
-
|
|
2428
|
+
_context27.next = 7;
|
|
2219
2429
|
return this.updateOrderProduct(params);
|
|
2220
2430
|
case 7:
|
|
2221
|
-
products =
|
|
2222
|
-
return
|
|
2431
|
+
products = _context27.sent;
|
|
2432
|
+
return _context27.abrupt("return", products);
|
|
2223
2433
|
case 11:
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
throw
|
|
2434
|
+
_context27.prev = 11;
|
|
2435
|
+
_context27.t0 = _context27["catch"](0);
|
|
2436
|
+
throw _context27.t0;
|
|
2227
2437
|
case 14:
|
|
2228
2438
|
case "end":
|
|
2229
|
-
return
|
|
2439
|
+
return _context27.stop();
|
|
2230
2440
|
}
|
|
2231
|
-
},
|
|
2441
|
+
}, _callee27, this, [[0, 11]]);
|
|
2232
2442
|
}));
|
|
2233
|
-
function setOrderProductLineNote(
|
|
2443
|
+
function setOrderProductLineNote(_x23, _x24) {
|
|
2234
2444
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
2235
2445
|
}
|
|
2236
2446
|
return setOrderProductLineNote;
|
|
@@ -2238,54 +2448,138 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2238
2448
|
}, {
|
|
2239
2449
|
key: "removeProductFromOrder",
|
|
2240
2450
|
value: function () {
|
|
2241
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2451
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
2242
2452
|
var products;
|
|
2243
|
-
return _regeneratorRuntime().wrap(function
|
|
2244
|
-
while (1) switch (
|
|
2453
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2454
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2245
2455
|
case 0:
|
|
2246
|
-
|
|
2456
|
+
_context28.prev = 0;
|
|
2247
2457
|
if (this.store.order) {
|
|
2248
|
-
|
|
2458
|
+
_context28.next = 3;
|
|
2249
2459
|
break;
|
|
2250
2460
|
}
|
|
2251
2461
|
throw new Error('order 模块未初始化');
|
|
2252
2462
|
case 3:
|
|
2253
|
-
|
|
2463
|
+
_context28.next = 5;
|
|
2254
2464
|
return this.store.order.removeProductFromOrder(identity);
|
|
2255
2465
|
case 5:
|
|
2256
|
-
products =
|
|
2257
|
-
return
|
|
2466
|
+
products = _context28.sent;
|
|
2467
|
+
return _context28.abrupt("return", products);
|
|
2258
2468
|
case 9:
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
throw
|
|
2469
|
+
_context28.prev = 9;
|
|
2470
|
+
_context28.t0 = _context28["catch"](0);
|
|
2471
|
+
throw _context28.t0;
|
|
2262
2472
|
case 12:
|
|
2263
2473
|
case "end":
|
|
2264
|
-
return
|
|
2474
|
+
return _context28.stop();
|
|
2265
2475
|
}
|
|
2266
|
-
},
|
|
2476
|
+
}, _callee28, this, [[0, 9]]);
|
|
2267
2477
|
}));
|
|
2268
|
-
function removeProductFromOrder(
|
|
2478
|
+
function removeProductFromOrder(_x25) {
|
|
2269
2479
|
return _removeProductFromOrder.apply(this, arguments);
|
|
2270
2480
|
}
|
|
2271
2481
|
return removeProductFromOrder;
|
|
2272
|
-
}() //
|
|
2482
|
+
}() // ─── 促销/赠品 透传(迁移自 booking usePromotion) ────────────────
|
|
2483
|
+
/**
|
|
2484
|
+
* 注入促销评估器到底层 OrderModule。
|
|
2485
|
+
*
|
|
2486
|
+
* @example
|
|
2487
|
+
* solution.setPromotionEvaluator(appHelper.utils.promotionEvaluator);
|
|
2488
|
+
*/
|
|
2489
|
+
}, {
|
|
2490
|
+
key: "setPromotionEvaluator",
|
|
2491
|
+
value: function setPromotionEvaluator(evaluator) {
|
|
2492
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2493
|
+
this.store.order.setPromotionEvaluator(evaluator);
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2496
|
+
/**
|
|
2497
|
+
* 注入赠品选择 resolver。UI 层(SalesSdk)通过 bridge 提供。
|
|
2498
|
+
*
|
|
2499
|
+
* @example
|
|
2500
|
+
* solution.setGiftSelectResolver(async (ctx) => bridge.request(ctx));
|
|
2501
|
+
*/
|
|
2502
|
+
}, {
|
|
2503
|
+
key: "setGiftSelectResolver",
|
|
2504
|
+
value: function setGiftSelectResolver(resolver) {
|
|
2505
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2506
|
+
this.store.order.setGiftSelectResolver(resolver);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
/**
|
|
2510
|
+
* 为商品目录追加促销标签,供 SalesSdkProductProvider 等商品列表入口复用。
|
|
2511
|
+
*
|
|
2512
|
+
* @example
|
|
2513
|
+
* const products = solution.appendPromotionTags(catalogProducts);
|
|
2514
|
+
*/
|
|
2515
|
+
}, {
|
|
2516
|
+
key: "appendPromotionTags",
|
|
2517
|
+
value: function appendPromotionTags(products) {
|
|
2518
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2519
|
+
return this.store.order.appendPromotionTags(products);
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
/**
|
|
2523
|
+
* 主动触发一次促销应用(一般写路径会自动触发,少数场景如客户切换后可手动调)。
|
|
2524
|
+
*/
|
|
2525
|
+
}, {
|
|
2526
|
+
key: "applyPromotion",
|
|
2527
|
+
value: (function () {
|
|
2528
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2529
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2530
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2531
|
+
case 0:
|
|
2532
|
+
if (this.store.order) {
|
|
2533
|
+
_context29.next = 2;
|
|
2534
|
+
break;
|
|
2535
|
+
}
|
|
2536
|
+
throw new Error('order 模块未初始化');
|
|
2537
|
+
case 2:
|
|
2538
|
+
_context29.next = 4;
|
|
2539
|
+
return this.store.order.applyPromotion();
|
|
2540
|
+
case 4:
|
|
2541
|
+
case "end":
|
|
2542
|
+
return _context29.stop();
|
|
2543
|
+
}
|
|
2544
|
+
}, _callee29, this);
|
|
2545
|
+
}));
|
|
2546
|
+
function applyPromotion() {
|
|
2547
|
+
return _applyPromotion.apply(this, arguments);
|
|
2548
|
+
}
|
|
2549
|
+
return applyPromotion;
|
|
2550
|
+
}() /** 最近一次促销计算输出的未满足提示。 */)
|
|
2551
|
+
}, {
|
|
2552
|
+
key: "getUnfulfilledPromotions",
|
|
2553
|
+
value: function getUnfulfilledPromotions() {
|
|
2554
|
+
var _this$store$order4;
|
|
2555
|
+
return ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getUnfulfilledPromotions()) || [];
|
|
2556
|
+
}
|
|
2557
|
+
|
|
2558
|
+
/** 最近一次促销计算输出的赠品操作 diff。 */
|
|
2559
|
+
}, {
|
|
2560
|
+
key: "getLastGiftActions",
|
|
2561
|
+
value: function getLastGiftActions() {
|
|
2562
|
+
var _this$store$order5;
|
|
2563
|
+
return ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getLastGiftActions()) || null;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
// 获取商品列表
|
|
2273
2567
|
// TODO 需要跟 webpos 内的对齐一下
|
|
2274
2568
|
}, {
|
|
2275
2569
|
key: "getProductList",
|
|
2276
2570
|
value: function () {
|
|
2277
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2278
|
-
var _this$
|
|
2571
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2572
|
+
var _this$otherParams8;
|
|
2279
2573
|
var menu_list_ids, _this$store$products, res;
|
|
2280
|
-
return _regeneratorRuntime().wrap(function
|
|
2281
|
-
while (1) switch (
|
|
2574
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2575
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2282
2576
|
case 0:
|
|
2283
2577
|
// 可以直接通过配置里的 menu 读取
|
|
2284
|
-
menu_list_ids = ((_this$
|
|
2578
|
+
menu_list_ids = ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 || (_this$otherParams8 = _this$otherParams8.dineInConfig) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8['menu.associated_menus'].map(function (n) {
|
|
2285
2579
|
return Number(n.value);
|
|
2286
2580
|
})) || [];
|
|
2287
|
-
|
|
2288
|
-
|
|
2581
|
+
_context30.prev = 1;
|
|
2582
|
+
_context30.next = 4;
|
|
2289
2583
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
2290
2584
|
menu_list_ids: menu_list_ids,
|
|
2291
2585
|
cacheId: this.cacheId,
|
|
@@ -2293,17 +2587,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2293
2587
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
2294
2588
|
});
|
|
2295
2589
|
case 4:
|
|
2296
|
-
res =
|
|
2297
|
-
return
|
|
2590
|
+
res = _context30.sent;
|
|
2591
|
+
return _context30.abrupt("return", res);
|
|
2298
2592
|
case 8:
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
throw
|
|
2593
|
+
_context30.prev = 8;
|
|
2594
|
+
_context30.t0 = _context30["catch"](1);
|
|
2595
|
+
throw _context30.t0;
|
|
2302
2596
|
case 11:
|
|
2303
2597
|
case "end":
|
|
2304
|
-
return
|
|
2598
|
+
return _context30.stop();
|
|
2305
2599
|
}
|
|
2306
|
-
},
|
|
2600
|
+
}, _callee30, this, [[1, 8]]);
|
|
2307
2601
|
}));
|
|
2308
2602
|
function getProductList() {
|
|
2309
2603
|
return _getProductList.apply(this, arguments);
|
|
@@ -2318,15 +2612,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2318
2612
|
}, {
|
|
2319
2613
|
key: "setOtherParams",
|
|
2320
2614
|
value: function () {
|
|
2321
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2322
|
-
var
|
|
2323
|
-
|
|
2615
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
2616
|
+
var _ref12,
|
|
2617
|
+
_ref12$cover,
|
|
2324
2618
|
cover,
|
|
2325
|
-
|
|
2326
|
-
return _regeneratorRuntime().wrap(function
|
|
2327
|
-
while (1) switch (
|
|
2619
|
+
_args31 = arguments;
|
|
2620
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2621
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2328
2622
|
case 0:
|
|
2329
|
-
|
|
2623
|
+
_ref12 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
|
|
2330
2624
|
if (cover) {
|
|
2331
2625
|
this.otherParams = params;
|
|
2332
2626
|
} else {
|
|
@@ -2334,11 +2628,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2334
2628
|
}
|
|
2335
2629
|
case 2:
|
|
2336
2630
|
case "end":
|
|
2337
|
-
return
|
|
2631
|
+
return _context31.stop();
|
|
2338
2632
|
}
|
|
2339
|
-
},
|
|
2633
|
+
}, _callee31, this);
|
|
2340
2634
|
}));
|
|
2341
|
-
function setOtherParams(
|
|
2635
|
+
function setOtherParams(_x26) {
|
|
2342
2636
|
return _setOtherParams.apply(this, arguments);
|
|
2343
2637
|
}
|
|
2344
2638
|
return setOtherParams;
|