@pisell/pisellos 2.2.171 → 2.2.173
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +33 -17
- package/dist/modules/Order/index.js +757 -395
- package/dist/modules/Order/types.d.ts +58 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +39 -1
- package/dist/modules/Order/utils.js +219 -31
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +113 -94
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +53 -7
- package/dist/solution/BaseSales/index.js +1160 -339
- package/dist/solution/BaseSales/types.d.ts +67 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +776 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +33 -17
- package/lib/modules/Order/index.js +402 -148
- package/lib/modules/Order/types.d.ts +58 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +39 -1
- package/lib/modules/Order/utils.js +197 -22
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +23 -12
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +53 -7
- package/lib/solution/BaseSales/index.js +527 -20
- package/lib/solution/BaseSales/types.d.ts +67 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +349 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -26,10 +26,11 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
26
26
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
28
|
import { OrderHooks } from "./types";
|
|
29
|
-
import { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments } from "./utils";
|
|
29
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, sumOptionUnitPrice, clearTempOrderHolderAssignments } from "./utils";
|
|
30
30
|
import { isNormalProduct } from "../Product/utils";
|
|
31
31
|
import dayjs from 'dayjs';
|
|
32
32
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
33
|
+
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
33
34
|
import { DiscountModule } from "../Discount";
|
|
34
35
|
import { RulesModule } from "../Rules";
|
|
35
36
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -59,6 +60,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
59
60
|
return _this;
|
|
60
61
|
}
|
|
61
62
|
_createClass(OrderModule, [{
|
|
63
|
+
key: "applyProductDiscountPrices",
|
|
64
|
+
value: function applyProductDiscountPrices(products) {
|
|
65
|
+
return (products || []).map(function (product) {
|
|
66
|
+
var _product$metadata, _product$metadata$sou, _product$metadata2, _product$metadata3, _product$original_pri;
|
|
67
|
+
if ((_product$metadata = product.metadata) !== null && _product$metadata !== void 0 && _product$metadata.is_manual_discount) return product;
|
|
68
|
+
var totalPerUnitDiscount = (product.discount_list || []).reduce(function (sum, discount) {
|
|
69
|
+
return sum + Number(discount.amount || 0);
|
|
70
|
+
}, 0);
|
|
71
|
+
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
72
|
+
var sourcePrice = (_product$metadata$sou = (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.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';
|
|
73
|
+
var newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
74
|
+
var newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
75
|
+
if (product.metadata) {
|
|
76
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
77
|
+
product.metadata.price_schema_version = 2;
|
|
78
|
+
}
|
|
79
|
+
product.selling_price = composeLinePrice({
|
|
80
|
+
mainPrice: newMainSellingPrice,
|
|
81
|
+
bundle: product.product_bundle
|
|
82
|
+
});
|
|
83
|
+
return product;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
62
87
|
key: "initialize",
|
|
63
88
|
value: function () {
|
|
64
89
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
@@ -94,9 +119,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
94
119
|
this.orderHooks = options.hooks || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
|
|
95
120
|
this.otherParams = otherParams;
|
|
96
121
|
this.registerDiscountModules(options);
|
|
97
|
-
this.restoreTempOrderFromStorage();
|
|
98
122
|
this.logInfo('OrderModule initialized successfully');
|
|
99
|
-
case
|
|
123
|
+
case 20:
|
|
100
124
|
case "end":
|
|
101
125
|
return _context.stop();
|
|
102
126
|
}
|
|
@@ -196,29 +220,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
220
|
key: "loadDiscountConfig",
|
|
197
221
|
value: function () {
|
|
198
222
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
199
|
-
var _this$store$discount, _this$store$
|
|
200
|
-
var discountList, _this$store$discount2;
|
|
223
|
+
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
224
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3;
|
|
201
225
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
202
226
|
while (1) switch (_context2.prev = _context2.next) {
|
|
203
227
|
case 0:
|
|
204
|
-
|
|
205
|
-
|
|
228
|
+
orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
|
|
229
|
+
_context2.next = 3;
|
|
230
|
+
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
|
|
206
231
|
customer_id: params.customerId,
|
|
207
|
-
action: params.action || 'create',
|
|
232
|
+
action: params.action || (orderId ? 'edit' : 'create'),
|
|
208
233
|
with_good_pass: 1,
|
|
209
234
|
with_discount_card: 1,
|
|
210
235
|
with_wallet_pass_holder: 1,
|
|
211
236
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
212
|
-
}
|
|
213
|
-
|
|
237
|
+
}, orderId ? {
|
|
238
|
+
order_id: orderId
|
|
239
|
+
} : {}));
|
|
240
|
+
case 3:
|
|
214
241
|
discountList = _context2.sent;
|
|
215
|
-
if (discountList) {
|
|
216
|
-
|
|
242
|
+
if (!discountList) {
|
|
243
|
+
_context2.next = 9;
|
|
244
|
+
break;
|
|
217
245
|
}
|
|
218
|
-
|
|
246
|
+
_context2.next = 7;
|
|
247
|
+
return (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.setOriginalDiscountList(discountList);
|
|
248
|
+
case 7:
|
|
249
|
+
_context2.next = 9;
|
|
250
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setDiscountList(discountList);
|
|
251
|
+
case 9:
|
|
252
|
+
if (params.apply !== false && (_this$store$tempOrder2 = this.store.tempOrder) !== null && _this$store$tempOrder2 !== void 0 && (_this$store$tempOrder2 = _this$store$tempOrder2.products) !== null && _this$store$tempOrder2 !== void 0 && _this$store$tempOrder2.length) {
|
|
219
253
|
this.applyDiscount();
|
|
220
254
|
}
|
|
221
|
-
|
|
255
|
+
return _context2.abrupt("return", this.getDiscountList());
|
|
256
|
+
case 11:
|
|
222
257
|
case "end":
|
|
223
258
|
return _context2.stop();
|
|
224
259
|
}
|
|
@@ -232,20 +267,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
232
267
|
}, {
|
|
233
268
|
key: "getDiscountList",
|
|
234
269
|
value: function getDiscountList() {
|
|
235
|
-
var _this$store$
|
|
236
|
-
return ((_this$store$
|
|
270
|
+
var _this$store$discount4;
|
|
271
|
+
return ((_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.getDiscountList()) || [];
|
|
237
272
|
}
|
|
238
273
|
}, {
|
|
239
274
|
key: "scanCode",
|
|
240
275
|
value: function () {
|
|
241
276
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
242
|
-
var _this$store$
|
|
243
|
-
var
|
|
277
|
+
var _this$store$discount5, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
|
|
278
|
+
var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount6;
|
|
244
279
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
245
280
|
while (1) switch (_context3.prev = _context3.next) {
|
|
246
281
|
case 0:
|
|
247
282
|
_context3.next = 2;
|
|
248
|
-
return (_this$store$
|
|
283
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.batchSearch(code, {
|
|
249
284
|
customerId: customerId
|
|
250
285
|
});
|
|
251
286
|
case 2:
|
|
@@ -254,36 +289,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
289
|
_context3.next = 5;
|
|
255
290
|
break;
|
|
256
291
|
}
|
|
257
|
-
_context3.t0 =
|
|
258
|
-
discountList: [],
|
|
259
|
-
unavailableReasonKey: null
|
|
260
|
-
};
|
|
292
|
+
_context3.t0 = [];
|
|
261
293
|
case 5:
|
|
262
|
-
|
|
263
|
-
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
294
|
+
resultDiscountList = _context3.t0;
|
|
264
295
|
rulesModule = this.store.rules;
|
|
265
296
|
if (rulesModule) {
|
|
266
|
-
_context3.next =
|
|
297
|
+
_context3.next = 9;
|
|
267
298
|
break;
|
|
268
299
|
}
|
|
269
300
|
return _context3.abrupt("return", {
|
|
270
301
|
type: 'clientCalc',
|
|
271
302
|
isAvailable: false,
|
|
272
303
|
discountList: this.getDiscountList(),
|
|
304
|
+
scannedDiscountList: resultDiscountList,
|
|
273
305
|
unavailableReason: UnavailableReason.Unknown
|
|
274
306
|
});
|
|
275
|
-
case
|
|
307
|
+
case 9:
|
|
276
308
|
if (resultDiscountList.length) {
|
|
277
|
-
_context3.next =
|
|
309
|
+
_context3.next = 11;
|
|
278
310
|
break;
|
|
279
311
|
}
|
|
280
312
|
return _context3.abrupt("return", {
|
|
281
313
|
type: 'server',
|
|
282
314
|
isAvailable: false,
|
|
283
315
|
discountList: this.getDiscountList(),
|
|
284
|
-
|
|
316
|
+
scannedDiscountList: resultDiscountList
|
|
285
317
|
});
|
|
286
|
-
case
|
|
318
|
+
case 11:
|
|
287
319
|
withScanList = resultDiscountList.map(function (item) {
|
|
288
320
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
289
321
|
isScan: true
|
|
@@ -297,15 +329,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
329
|
return m.id === n.id;
|
|
298
330
|
});
|
|
299
331
|
}))) {
|
|
300
|
-
_context3.next =
|
|
332
|
+
_context3.next = 15;
|
|
301
333
|
break;
|
|
302
334
|
}
|
|
303
335
|
return _context3.abrupt("return", {
|
|
304
336
|
type: 'clientCalc',
|
|
305
337
|
isAvailable: true,
|
|
306
|
-
discountList: this.getDiscountList()
|
|
338
|
+
discountList: this.getDiscountList(),
|
|
339
|
+
scannedDiscountList: resultDiscountList
|
|
307
340
|
});
|
|
308
|
-
case
|
|
341
|
+
case 15:
|
|
309
342
|
tempOrder = this.store.tempOrder;
|
|
310
343
|
holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
311
344
|
form_record_id: tempOrder.holder.form_record_id
|
|
@@ -322,16 +355,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
322
355
|
discountList: this.getDiscountList()
|
|
323
356
|
}, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
|
|
324
357
|
if (isAvailable && newDiscountList) {
|
|
325
|
-
(_this$store$
|
|
358
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
326
359
|
this.applyDiscount();
|
|
327
360
|
}
|
|
328
361
|
return _context3.abrupt("return", {
|
|
329
362
|
type: 'clientCalc',
|
|
330
363
|
isAvailable: isAvailable || false,
|
|
331
364
|
discountList: newDiscountList || this.getDiscountList(),
|
|
365
|
+
scannedDiscountList: resultDiscountList,
|
|
332
366
|
unavailableReason: unavailableReason
|
|
333
367
|
});
|
|
334
|
-
case
|
|
368
|
+
case 20:
|
|
335
369
|
case "end":
|
|
336
370
|
return _context3.stop();
|
|
337
371
|
}
|
|
@@ -345,15 +379,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
345
379
|
}, {
|
|
346
380
|
key: "applyDiscount",
|
|
347
381
|
value: function applyDiscount() {
|
|
348
|
-
var _this$store$
|
|
382
|
+
var _this$store$discount7, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
|
|
349
383
|
var tempOrder = this.store.tempOrder;
|
|
350
384
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
351
385
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
352
|
-
// appliedProductDetails / savedAmount
|
|
386
|
+
// appliedProductDetails / savedAmount 复位。
|
|
353
387
|
if (!tempOrder) return;
|
|
388
|
+
delete tempOrder.discount_list;
|
|
354
389
|
var rulesModule = this.store.rules;
|
|
355
390
|
if (!rulesModule) return;
|
|
356
|
-
var discountList = ((_this$store$
|
|
391
|
+
var discountList = ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
357
392
|
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
358
393
|
form_record_id: tempOrder.holder.form_record_id
|
|
359
394
|
}] : [];
|
|
@@ -365,15 +400,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
365
400
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
366
401
|
});
|
|
367
402
|
if (result !== null && result !== void 0 && result.productList) {
|
|
368
|
-
tempOrder.products = result.productList
|
|
403
|
+
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product) {
|
|
404
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
405
|
+
discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(product.discount_list, product.num))
|
|
406
|
+
});
|
|
407
|
+
}));
|
|
369
408
|
}
|
|
370
409
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
371
|
-
var _this$store$
|
|
410
|
+
var _this$store$discount8;
|
|
372
411
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
373
|
-
(_this$store$
|
|
374
|
-
tempOrder.discount_list = result.discountList.filter(function (d) {
|
|
375
|
-
return d.isSelected;
|
|
376
|
-
});
|
|
412
|
+
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(result.discountList);
|
|
377
413
|
}
|
|
378
414
|
}
|
|
379
415
|
|
|
@@ -383,76 +419,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
383
419
|
value: function initTempOrder(params) {
|
|
384
420
|
if (params.cacheId !== undefined) this.cacheId = params.cacheId;
|
|
385
421
|
if (params.salesSummaryModuleName !== undefined) this.salesSummaryModuleName = params.salesSummaryModuleName;
|
|
386
|
-
this.restoreTempOrderFromStorage();
|
|
387
422
|
}
|
|
388
423
|
|
|
389
|
-
|
|
424
|
+
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
390
425
|
}, {
|
|
391
|
-
key: "
|
|
392
|
-
value: function
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
426
|
+
key: "setEnableTempOrderPersist",
|
|
427
|
+
value: function setEnableTempOrderPersist(_enabled) {}
|
|
428
|
+
|
|
429
|
+
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
|
|
396
430
|
}, {
|
|
397
|
-
key: "
|
|
398
|
-
value: function
|
|
399
|
-
|
|
400
|
-
if (!key) return;
|
|
401
|
-
if (!this.window) return;
|
|
402
|
-
var cachedData = this.window.localStorage.getItem(key);
|
|
403
|
-
if (!cachedData) return;
|
|
404
|
-
try {
|
|
405
|
-
var parsedData = JSON.parse(cachedData);
|
|
406
|
-
if (!isTempOrder(parsedData)) {
|
|
407
|
-
this.window.localStorage.removeItem(key);
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
if (Array.isArray(parsedData.products)) {
|
|
411
|
-
for (var i = 0; i < parsedData.products.length; i++) {
|
|
412
|
-
var p = parsedData.products[i];
|
|
413
|
-
if (!p || _typeof(p) !== 'object') continue;
|
|
414
|
-
if (!Array.isArray(p.product_option_item)) {
|
|
415
|
-
p.product_option_item = [];
|
|
416
|
-
}
|
|
417
|
-
if (!Array.isArray(p.product_bundle)) {
|
|
418
|
-
p.product_bundle = [];
|
|
419
|
-
}
|
|
420
|
-
var row = p;
|
|
421
|
-
// 价格 schema 迁移:重跑 normalizeOrderProduct。
|
|
422
|
-
// `metadata.price_schema_version === 2` → 已是新语义,保留现有 main_product_* 折扣;
|
|
423
|
-
// 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
|
|
424
|
-
// 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
|
|
425
|
-
// 幂等:多次 restore 不会重复叠加 option/bundle。
|
|
426
|
-
parsedData.products[i] = normalizeOrderProduct(row);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
var parsedRecord = parsedData;
|
|
430
|
-
this.store.summary = parsedRecord.summary || createEmptySummary();
|
|
431
|
-
delete parsedData.summary;
|
|
432
|
-
if (parsedRecord.lastOrderInfo) {
|
|
433
|
-
this.store.lastOrderInfo = parsedRecord.lastOrderInfo;
|
|
434
|
-
delete parsedData.lastOrderInfo;
|
|
435
|
-
}
|
|
436
|
-
if (!parsedData._extend || _typeof(parsedData._extend) !== 'object') {
|
|
437
|
-
parsedData._extend = {
|
|
438
|
-
productsByUid: {}
|
|
439
|
-
};
|
|
440
|
-
} else if (!parsedData._extend.productsByUid) {
|
|
441
|
-
parsedData._extend.productsByUid = {};
|
|
442
|
-
}
|
|
443
|
-
this.store.tempOrder = parsedData;
|
|
444
|
-
} catch (_unused2) {
|
|
445
|
-
var _this$window;
|
|
446
|
-
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
|
|
447
|
-
}
|
|
431
|
+
key: "isTempOrderPersistEnabled",
|
|
432
|
+
value: function isTempOrderPersistEnabled() {
|
|
433
|
+
return false;
|
|
448
434
|
}
|
|
435
|
+
|
|
436
|
+
/** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化;草稿保存请使用 IndexedDB saveDraft。 */
|
|
449
437
|
}, {
|
|
450
438
|
key: "persistTempOrder",
|
|
451
439
|
value: function persistTempOrder() {
|
|
452
|
-
|
|
453
|
-
if (!key || !this.store.tempOrder) return;
|
|
454
|
-
if (!this.window) return;
|
|
455
|
-
this.window.localStorage.setItem(key, JSON.stringify(this.store.tempOrder));
|
|
440
|
+
// no-op: OrderModule 的刷新恢复不再依赖 localStorage。
|
|
456
441
|
}
|
|
457
442
|
|
|
458
443
|
// ─── TempOrder: 创建 & 获取 ───
|
|
@@ -721,6 +706,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
721
706
|
}
|
|
722
707
|
return saveDraft;
|
|
723
708
|
}()
|
|
709
|
+
}, {
|
|
710
|
+
key: "saveDraftInBackground",
|
|
711
|
+
value: function saveDraftInBackground() {
|
|
712
|
+
void this.saveDraft();
|
|
713
|
+
}
|
|
724
714
|
}, {
|
|
725
715
|
key: "hydrateTempOrderFromLocalRecord",
|
|
726
716
|
value: function () {
|
|
@@ -812,11 +802,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
812
802
|
}, {
|
|
813
803
|
key: "restoreOrder",
|
|
814
804
|
value: function restoreOrder() {
|
|
805
|
+
var _this$store$discount9, _this$store$discount10;
|
|
815
806
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
816
807
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
817
808
|
this.store.tempOrder = freshTempOrder;
|
|
818
809
|
this.store.summary = createEmptySummary();
|
|
819
810
|
this.store.lastOrderInfo = undefined;
|
|
811
|
+
this.store.syncState = undefined;
|
|
812
|
+
void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
|
|
813
|
+
void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
|
|
820
814
|
this.persistTempOrder();
|
|
821
815
|
return freshTempOrder;
|
|
822
816
|
}
|
|
@@ -825,6 +819,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
825
819
|
value: function getTempOrder() {
|
|
826
820
|
return this.store.tempOrder;
|
|
827
821
|
}
|
|
822
|
+
}, {
|
|
823
|
+
key: "replaceTempOrder",
|
|
824
|
+
value: function () {
|
|
825
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
|
|
826
|
+
var nextTempOrder;
|
|
827
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
828
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
829
|
+
case 0:
|
|
830
|
+
if (isTempOrder(tempOrder)) {
|
|
831
|
+
_context9.next = 2;
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
throw new Error('无效的 tempOrder 数据');
|
|
835
|
+
case 2:
|
|
836
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
|
|
837
|
+
ensureIdentity: false
|
|
838
|
+
});
|
|
839
|
+
this.store.tempOrder = nextTempOrder;
|
|
840
|
+
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
841
|
+
_context9.next = 9;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
_context9.next = 7;
|
|
845
|
+
return this.recalculateSummary({
|
|
846
|
+
createIfMissing: false
|
|
847
|
+
});
|
|
848
|
+
case 7:
|
|
849
|
+
_context9.next = 10;
|
|
850
|
+
break;
|
|
851
|
+
case 9:
|
|
852
|
+
this.store.summary = createEmptySummary();
|
|
853
|
+
case 10:
|
|
854
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
855
|
+
this.persistTempOrder();
|
|
856
|
+
}
|
|
857
|
+
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
858
|
+
_context9.next = 14;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
_context9.next = 14;
|
|
862
|
+
return this.saveDraft();
|
|
863
|
+
case 14:
|
|
864
|
+
return _context9.abrupt("return", nextTempOrder);
|
|
865
|
+
case 15:
|
|
866
|
+
case "end":
|
|
867
|
+
return _context9.stop();
|
|
868
|
+
}
|
|
869
|
+
}, _callee9, this);
|
|
870
|
+
}));
|
|
871
|
+
function replaceTempOrder(_x10, _x11) {
|
|
872
|
+
return _replaceTempOrder.apply(this, arguments);
|
|
873
|
+
}
|
|
874
|
+
return replaceTempOrder;
|
|
875
|
+
}()
|
|
828
876
|
}, {
|
|
829
877
|
key: "getOrderIdentity",
|
|
830
878
|
value: function getOrderIdentity() {
|
|
@@ -903,28 +951,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
951
|
}, {
|
|
904
952
|
key: "addNewOrder",
|
|
905
953
|
value: function () {
|
|
906
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
954
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
907
955
|
var tempOrder;
|
|
908
|
-
return _regeneratorRuntime().wrap(function
|
|
909
|
-
while (1) switch (
|
|
956
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
957
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
910
958
|
case 0:
|
|
911
959
|
tempOrder = this.ensureTempOrder();
|
|
912
960
|
this.ensureExternalSaleNumber(tempOrder);
|
|
913
|
-
|
|
961
|
+
_context10.next = 4;
|
|
914
962
|
return this.recalculateSummary({
|
|
915
963
|
createIfMissing: true
|
|
916
964
|
});
|
|
917
965
|
case 4:
|
|
918
966
|
this.persistTempOrder();
|
|
919
|
-
|
|
967
|
+
_context10.next = 7;
|
|
920
968
|
return this.saveDraft();
|
|
921
969
|
case 7:
|
|
922
|
-
return
|
|
970
|
+
return _context10.abrupt("return", tempOrder);
|
|
923
971
|
case 8:
|
|
924
972
|
case "end":
|
|
925
|
-
return
|
|
973
|
+
return _context10.stop();
|
|
926
974
|
}
|
|
927
|
-
},
|
|
975
|
+
}, _callee10, this);
|
|
928
976
|
}));
|
|
929
977
|
function addNewOrder() {
|
|
930
978
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1000,6 +1048,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1048
|
})
|
|
1001
1049
|
};
|
|
1002
1050
|
}
|
|
1051
|
+
}, {
|
|
1052
|
+
key: "getBookingUniqueIdentificationNumber",
|
|
1053
|
+
value: function getBookingUniqueIdentificationNumber(booking) {
|
|
1054
|
+
var _booking$metadata;
|
|
1055
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
|
|
1056
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
1057
|
+
return String(uid);
|
|
1058
|
+
}
|
|
1059
|
+
}, {
|
|
1060
|
+
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
1061
|
+
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
1062
|
+
var _this3 = this;
|
|
1063
|
+
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
1064
|
+
return _this3.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
}, {
|
|
1068
|
+
key: "removeLinkedBookingsForProduct",
|
|
1069
|
+
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
1070
|
+
var _product$metadata4,
|
|
1071
|
+
_product$metadata5,
|
|
1072
|
+
_this4 = this;
|
|
1073
|
+
var productUid = (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
1074
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid);
|
|
1075
|
+
if (!productUid && !bookingUid) return;
|
|
1076
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
1077
|
+
var currentBookingUid = _this4.getBookingUniqueIdentificationNumber(booking);
|
|
1078
|
+
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
1079
|
+
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
1080
|
+
return true;
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1003
1083
|
|
|
1004
1084
|
// ─── TempOrder: 金额汇总 ───
|
|
1005
1085
|
}, {
|
|
@@ -1011,23 +1091,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1011
1091
|
}, {
|
|
1012
1092
|
key: "recalculateSummary",
|
|
1013
1093
|
value: function () {
|
|
1014
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1094
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
1015
1095
|
var tempOrder, salesSummary, existedSummary, paidPaymentSummary, emptySummary, salesSummaryResult, summary;
|
|
1016
|
-
return _regeneratorRuntime().wrap(function
|
|
1017
|
-
while (1) switch (
|
|
1096
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1097
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1018
1098
|
case 0:
|
|
1019
1099
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1020
1100
|
if (tempOrder) {
|
|
1021
|
-
|
|
1101
|
+
_context11.next = 3;
|
|
1022
1102
|
break;
|
|
1023
1103
|
}
|
|
1024
|
-
return
|
|
1104
|
+
return _context11.abrupt("return", null);
|
|
1025
1105
|
case 3:
|
|
1026
1106
|
salesSummary = this.getSalesSummary();
|
|
1027
1107
|
existedSummary = this.store.summary || createEmptySummary();
|
|
1028
1108
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1029
1109
|
if (salesSummary) {
|
|
1030
|
-
|
|
1110
|
+
_context11.next = 11;
|
|
1031
1111
|
break;
|
|
1032
1112
|
}
|
|
1033
1113
|
emptySummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
|
|
@@ -1038,16 +1118,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1118
|
});
|
|
1039
1119
|
this.store.summary = emptySummary;
|
|
1040
1120
|
tempOrder.surcharge_fee = emptySummary.surcharge_fee;
|
|
1041
|
-
return
|
|
1121
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1042
1122
|
case 11:
|
|
1043
|
-
|
|
1123
|
+
_context11.next = 13;
|
|
1044
1124
|
return salesSummary.getSummary({
|
|
1045
1125
|
products: tempOrder.products,
|
|
1046
1126
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1047
1127
|
shopDiscount: tempOrder.shop_discount
|
|
1048
1128
|
});
|
|
1049
1129
|
case 13:
|
|
1050
|
-
salesSummaryResult =
|
|
1130
|
+
salesSummaryResult = _context11.sent;
|
|
1051
1131
|
summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
1052
1132
|
total_refund_amount: existedSummary.total_refund_amount || '0.00',
|
|
1053
1133
|
customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
|
|
@@ -1065,14 +1145,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1065
1145
|
tempOrder.surcharges = summary.surcharges || [];
|
|
1066
1146
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
1067
1147
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
1068
|
-
return
|
|
1148
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1069
1149
|
case 23:
|
|
1070
1150
|
case "end":
|
|
1071
|
-
return
|
|
1151
|
+
return _context11.stop();
|
|
1072
1152
|
}
|
|
1073
|
-
},
|
|
1153
|
+
}, _callee11, this);
|
|
1074
1154
|
}));
|
|
1075
|
-
function recalculateSummary(
|
|
1155
|
+
function recalculateSummary(_x12) {
|
|
1076
1156
|
return _recalculateSummary.apply(this, arguments);
|
|
1077
1157
|
}
|
|
1078
1158
|
return recalculateSummary;
|
|
@@ -1080,30 +1160,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1080
1160
|
}, {
|
|
1081
1161
|
key: "getOrderSummary",
|
|
1082
1162
|
value: function () {
|
|
1083
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1163
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1084
1164
|
var summary;
|
|
1085
|
-
return _regeneratorRuntime().wrap(function
|
|
1086
|
-
while (1) switch (
|
|
1165
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1166
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1087
1167
|
case 0:
|
|
1088
|
-
|
|
1168
|
+
_context12.next = 2;
|
|
1089
1169
|
return this.recalculateSummary({
|
|
1090
1170
|
createIfMissing: true
|
|
1091
1171
|
});
|
|
1092
1172
|
case 2:
|
|
1093
|
-
summary =
|
|
1173
|
+
summary = _context12.sent;
|
|
1094
1174
|
if (summary) {
|
|
1095
|
-
|
|
1175
|
+
_context12.next = 5;
|
|
1096
1176
|
break;
|
|
1097
1177
|
}
|
|
1098
|
-
return
|
|
1178
|
+
return _context12.abrupt("return", createEmptySummary());
|
|
1099
1179
|
case 5:
|
|
1100
1180
|
this.persistTempOrder();
|
|
1101
|
-
return
|
|
1181
|
+
return _context12.abrupt("return", summary);
|
|
1102
1182
|
case 7:
|
|
1103
1183
|
case "end":
|
|
1104
|
-
return
|
|
1184
|
+
return _context12.stop();
|
|
1105
1185
|
}
|
|
1106
|
-
},
|
|
1186
|
+
}, _callee12, this);
|
|
1107
1187
|
}));
|
|
1108
1188
|
function getOrderSummary() {
|
|
1109
1189
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -1113,16 +1193,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1113
1193
|
}, {
|
|
1114
1194
|
key: "updateTempOrderNote",
|
|
1115
1195
|
value: function updateTempOrderNote(note) {
|
|
1196
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1116
1197
|
var tempOrder = this.ensureTempOrder();
|
|
1117
1198
|
tempOrder.note = String(note || '');
|
|
1118
1199
|
this.persistTempOrder();
|
|
1200
|
+
if (sync) {
|
|
1201
|
+
var orderId = tempOrder.order_id;
|
|
1202
|
+
if (!orderId) return tempOrder.note;
|
|
1203
|
+
return this.syncTempOrderNoteToRemote(orderId, tempOrder.note);
|
|
1204
|
+
}
|
|
1119
1205
|
return tempOrder.note;
|
|
1120
1206
|
}
|
|
1207
|
+
}, {
|
|
1208
|
+
key: "syncTempOrderNoteToRemote",
|
|
1209
|
+
value: function () {
|
|
1210
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
|
|
1211
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1212
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1213
|
+
case 0:
|
|
1214
|
+
_context13.next = 2;
|
|
1215
|
+
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
1216
|
+
note: note
|
|
1217
|
+
});
|
|
1218
|
+
case 2:
|
|
1219
|
+
return _context13.abrupt("return", note);
|
|
1220
|
+
case 3:
|
|
1221
|
+
case "end":
|
|
1222
|
+
return _context13.stop();
|
|
1223
|
+
}
|
|
1224
|
+
}, _callee13, this);
|
|
1225
|
+
}));
|
|
1226
|
+
function syncTempOrderNoteToRemote(_x13, _x14) {
|
|
1227
|
+
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
1228
|
+
}
|
|
1229
|
+
return syncTempOrderNoteToRemote;
|
|
1230
|
+
}()
|
|
1121
1231
|
}, {
|
|
1122
1232
|
key: "getTempOrderNote",
|
|
1123
1233
|
value: function getTempOrderNote() {
|
|
1124
|
-
var _this$store$
|
|
1125
|
-
return ((_this$store$
|
|
1234
|
+
var _this$store$tempOrder3;
|
|
1235
|
+
return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
|
|
1126
1236
|
}
|
|
1127
1237
|
}, {
|
|
1128
1238
|
key: "updateTempOrderShopDiscount",
|
|
@@ -1149,25 +1259,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1149
1259
|
this.persistTempOrder();
|
|
1150
1260
|
return tempOrder.contacts_info;
|
|
1151
1261
|
}
|
|
1262
|
+
}, {
|
|
1263
|
+
key: "buildTempOrderCustomer",
|
|
1264
|
+
value: function buildTempOrderCustomer(params) {
|
|
1265
|
+
var _ref8, _ref9, _ref10, _source$name, _ref11, _ref12, _ref13, _source$customer_name, _source$id, _source$customer_id, _ref14, _source$country_calli, _source$phone, _source$email;
|
|
1266
|
+
if (!params.customerId) return null;
|
|
1267
|
+
var source = params.source ? cloneDeep(params.source) : {};
|
|
1268
|
+
var name = (_ref8 = (_ref9 = (_ref10 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref10 !== void 0 ? _ref10 : source.customerName) !== null && _ref9 !== void 0 ? _ref9 : source.customer_name) !== null && _ref8 !== void 0 ? _ref8 : params.customerName;
|
|
1269
|
+
var customerName = (_ref11 = (_ref12 = (_ref13 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref13 !== void 0 ? _ref13 : source.display_name) !== null && _ref12 !== void 0 ? _ref12 : source.name) !== null && _ref11 !== void 0 ? _ref11 : params.customerName;
|
|
1270
|
+
return _objectSpread(_objectSpread({}, source), {}, {
|
|
1271
|
+
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
1272
|
+
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
1273
|
+
name: String(name || ''),
|
|
1274
|
+
customer_name: String(customerName || ''),
|
|
1275
|
+
country_calling_code: String((_ref14 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref14 !== void 0 ? _ref14 : params.countryCallingCode),
|
|
1276
|
+
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
1277
|
+
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1152
1280
|
|
|
1153
1281
|
/**
|
|
1154
1282
|
* 更新当前 tempOrder 的客户协议字段。
|
|
1155
1283
|
*
|
|
1156
|
-
* PaymentModal
|
|
1284
|
+
* PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
|
|
1157
1285
|
* 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
|
|
1158
1286
|
*/
|
|
1159
1287
|
}, {
|
|
1160
1288
|
key: "updateTempOrderCustomer",
|
|
1161
1289
|
value: function updateTempOrderCustomer(customer) {
|
|
1162
|
-
var
|
|
1290
|
+
var _ref15, _ref16, _customer$customer_id, _ref17, _ref18, _ref19, _customer$customer_na, _ref20, _customer$country_cal;
|
|
1163
1291
|
var tempOrder = this.ensureTempOrder();
|
|
1164
|
-
var customerId = (
|
|
1165
|
-
var customerName = (
|
|
1292
|
+
var customerId = (_ref15 = (_ref16 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref16 !== void 0 ? _ref16 : customer.id) !== null && _ref15 !== void 0 ? _ref15 : null;
|
|
1293
|
+
var customerName = (_ref17 = (_ref18 = (_ref19 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref19 !== void 0 ? _ref19 : customer.display_name) !== null && _ref18 !== void 0 ? _ref18 : customer.name) !== null && _ref17 !== void 0 ? _ref17 : '';
|
|
1166
1294
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
1167
1295
|
tempOrder.customer_name = String(customerName || '');
|
|
1168
|
-
tempOrder.country_calling_code = String((
|
|
1296
|
+
tempOrder.country_calling_code = String((_ref20 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref20 !== void 0 ? _ref20 : '');
|
|
1169
1297
|
tempOrder.phone = String(customer.phone || '');
|
|
1170
1298
|
tempOrder.email = String(customer.email || '');
|
|
1299
|
+
tempOrder.customer = this.buildTempOrderCustomer({
|
|
1300
|
+
source: customer,
|
|
1301
|
+
customerId: tempOrder.customer_id,
|
|
1302
|
+
customerName: tempOrder.customer_name,
|
|
1303
|
+
countryCallingCode: tempOrder.country_calling_code,
|
|
1304
|
+
phone: tempOrder.phone,
|
|
1305
|
+
email: tempOrder.email
|
|
1306
|
+
});
|
|
1171
1307
|
this.persistTempOrder();
|
|
1172
1308
|
return {
|
|
1173
1309
|
customerId: tempOrder.customer_id,
|
|
@@ -1179,28 +1315,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1179
1315
|
}, {
|
|
1180
1316
|
key: "setOrderCustomer",
|
|
1181
1317
|
value: function setOrderCustomer(patch, snapshot) {
|
|
1318
|
+
var _tempOrder$customer_i2, _tempOrder$customer_i3;
|
|
1182
1319
|
if (!patch) {
|
|
1183
1320
|
this.clearOrderCustomer();
|
|
1184
1321
|
return;
|
|
1185
1322
|
}
|
|
1186
1323
|
var tempOrder = this.ensureTempOrder();
|
|
1324
|
+
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
1187
1325
|
tempOrder.customer_id = patch.customer_id || patch.id || null;
|
|
1188
1326
|
tempOrder.customer_name = String(patch.customer_name || '');
|
|
1189
1327
|
tempOrder.country_calling_code = String(patch.country_calling_code || '');
|
|
1190
1328
|
tempOrder.phone = String(patch.phone || '');
|
|
1191
1329
|
tempOrder.email = String(patch.email || '');
|
|
1330
|
+
tempOrder.customer = this.buildTempOrderCustomer({
|
|
1331
|
+
source: snapshot || null,
|
|
1332
|
+
customerId: tempOrder.customer_id,
|
|
1333
|
+
customerName: tempOrder.customer_name,
|
|
1334
|
+
countryCallingCode: tempOrder.country_calling_code,
|
|
1335
|
+
phone: tempOrder.phone,
|
|
1336
|
+
email: tempOrder.email
|
|
1337
|
+
});
|
|
1192
1338
|
if (snapshot !== undefined) {
|
|
1193
1339
|
var extend = this.ensureExtend(tempOrder);
|
|
1194
1340
|
if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
|
|
1195
1341
|
}
|
|
1342
|
+
var nextCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
1343
|
+
if (String(previousCustomerId !== null && previousCustomerId !== void 0 ? previousCustomerId : '') !== String(nextCustomerId !== null && nextCustomerId !== void 0 ? nextCustomerId : '')) {
|
|
1344
|
+
clearTempOrderHolderAssignments(tempOrder);
|
|
1345
|
+
}
|
|
1196
1346
|
this.persistTempOrder();
|
|
1347
|
+
this.saveDraftInBackground();
|
|
1197
1348
|
this.emitOrderCustomerChange();
|
|
1198
1349
|
}
|
|
1199
1350
|
}, {
|
|
1200
1351
|
key: "getOrderCustomer",
|
|
1201
1352
|
value: function getOrderCustomer() {
|
|
1202
1353
|
var tempOrder = this.store.tempOrder;
|
|
1203
|
-
if (!tempOrder || tempOrder.customer_id
|
|
1354
|
+
if (!tempOrder || !tempOrder.customer_id) {
|
|
1204
1355
|
return null;
|
|
1205
1356
|
}
|
|
1206
1357
|
return {
|
|
@@ -1214,21 +1365,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1214
1365
|
}, {
|
|
1215
1366
|
key: "getOrderCustomerSnapshot",
|
|
1216
1367
|
value: function getOrderCustomerSnapshot() {
|
|
1217
|
-
var _this$store$
|
|
1218
|
-
var snapshot = (_this$store$
|
|
1368
|
+
var _this$store$tempOrder4;
|
|
1369
|
+
var snapshot = (_this$store$tempOrder4 = this.store.tempOrder) === null || _this$store$tempOrder4 === void 0 || (_this$store$tempOrder4 = _this$store$tempOrder4._extend) === null || _this$store$tempOrder4 === void 0 ? void 0 : _this$store$tempOrder4.customerSnapshot;
|
|
1219
1370
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
1220
1371
|
}
|
|
1221
1372
|
}, {
|
|
1222
1373
|
key: "clearOrderCustomer",
|
|
1223
1374
|
value: function clearOrderCustomer() {
|
|
1224
1375
|
var tempOrder = this.ensureTempOrder();
|
|
1376
|
+
clearTempOrderHolderAssignments(tempOrder);
|
|
1225
1377
|
tempOrder.customer_id = null;
|
|
1226
1378
|
tempOrder.customer_name = '';
|
|
1227
1379
|
tempOrder.country_calling_code = '';
|
|
1228
1380
|
tempOrder.phone = '';
|
|
1229
1381
|
tempOrder.email = '';
|
|
1382
|
+
tempOrder.customer = null;
|
|
1230
1383
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
1231
1384
|
this.persistTempOrder();
|
|
1385
|
+
this.saveDraftInBackground();
|
|
1232
1386
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
1233
1387
|
}
|
|
1234
1388
|
}, {
|
|
@@ -1279,6 +1433,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1279
1433
|
}, {
|
|
1280
1434
|
key: "addOrderPayment",
|
|
1281
1435
|
value: function addOrderPayment(payment) {
|
|
1436
|
+
this.logInfo('addOrderPayment', {
|
|
1437
|
+
payment: payment
|
|
1438
|
+
});
|
|
1282
1439
|
var tempOrder = this.ensureTempOrder();
|
|
1283
1440
|
var mapped = mapPaymentItemsToOrderPayments([payment]);
|
|
1284
1441
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
@@ -1358,45 +1515,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1515
|
}, {
|
|
1359
1516
|
key: "shouldMergeProductToOrder",
|
|
1360
1517
|
value: function () {
|
|
1361
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1518
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1362
1519
|
var _this$orderHooks;
|
|
1363
1520
|
var onBeforeMergeProductToOrder, result;
|
|
1364
|
-
return _regeneratorRuntime().wrap(function
|
|
1365
|
-
while (1) switch (
|
|
1521
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1522
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1366
1523
|
case 0:
|
|
1367
1524
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
1368
1525
|
if (onBeforeMergeProductToOrder) {
|
|
1369
|
-
|
|
1526
|
+
_context14.next = 3;
|
|
1370
1527
|
break;
|
|
1371
1528
|
}
|
|
1372
|
-
return
|
|
1529
|
+
return _context14.abrupt("return", true);
|
|
1373
1530
|
case 3:
|
|
1374
|
-
|
|
1531
|
+
_context14.next = 5;
|
|
1375
1532
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
1376
1533
|
defaultShouldMerge: true
|
|
1377
1534
|
}));
|
|
1378
1535
|
case 5:
|
|
1379
|
-
result =
|
|
1536
|
+
result = _context14.sent;
|
|
1380
1537
|
if (!(typeof result === 'boolean')) {
|
|
1381
|
-
|
|
1538
|
+
_context14.next = 8;
|
|
1382
1539
|
break;
|
|
1383
1540
|
}
|
|
1384
|
-
return
|
|
1541
|
+
return _context14.abrupt("return", result);
|
|
1385
1542
|
case 8:
|
|
1386
1543
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
1387
|
-
|
|
1544
|
+
_context14.next = 10;
|
|
1388
1545
|
break;
|
|
1389
1546
|
}
|
|
1390
|
-
return
|
|
1547
|
+
return _context14.abrupt("return", result.shouldMerge);
|
|
1391
1548
|
case 10:
|
|
1392
|
-
return
|
|
1549
|
+
return _context14.abrupt("return", true);
|
|
1393
1550
|
case 11:
|
|
1394
1551
|
case "end":
|
|
1395
|
-
return
|
|
1552
|
+
return _context14.stop();
|
|
1396
1553
|
}
|
|
1397
|
-
},
|
|
1554
|
+
}, _callee14, this);
|
|
1398
1555
|
}));
|
|
1399
|
-
function shouldMergeProductToOrder(
|
|
1556
|
+
function shouldMergeProductToOrder(_x15) {
|
|
1400
1557
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
1401
1558
|
}
|
|
1402
1559
|
return shouldMergeProductToOrder;
|
|
@@ -1404,11 +1561,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1404
1561
|
}, {
|
|
1405
1562
|
key: "addProductToOrder",
|
|
1406
1563
|
value: function () {
|
|
1407
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1408
|
-
var
|
|
1564
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
|
|
1565
|
+
var _this5 = this;
|
|
1409
1566
|
var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
|
|
1410
|
-
return _regeneratorRuntime().wrap(function
|
|
1411
|
-
while (1) switch (
|
|
1567
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1568
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1412
1569
|
case 0:
|
|
1413
1570
|
tempOrder = this.ensureTempOrder();
|
|
1414
1571
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
@@ -1418,10 +1575,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1418
1575
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
1419
1576
|
incomingFingerprint = buildProductLineFingerprint(productToAdd.product_option_item, productToAdd.product_bundle);
|
|
1420
1577
|
normalizedIncoming = normalizeOrderProduct(productToAdd);
|
|
1578
|
+
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
1421
1579
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
1422
1580
|
shouldForceNewLine = !!booking;
|
|
1423
1581
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
1424
|
-
if (
|
|
1582
|
+
if (_this5.hasGoodPassDiscount(item)) return false;
|
|
1425
1583
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
1426
1584
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
1427
1585
|
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
@@ -1430,10 +1588,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1430
1588
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
1431
1589
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
|
|
1432
1590
|
if (!matchedProduct) {
|
|
1433
|
-
|
|
1591
|
+
_context15.next = 17;
|
|
1434
1592
|
break;
|
|
1435
1593
|
}
|
|
1436
|
-
|
|
1594
|
+
_context15.next = 14;
|
|
1437
1595
|
return this.shouldMergeProductToOrder({
|
|
1438
1596
|
incomingProduct: productToAdd,
|
|
1439
1597
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -1444,14 +1602,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1444
1602
|
tempOrder: tempOrder,
|
|
1445
1603
|
booking: booking
|
|
1446
1604
|
});
|
|
1447
|
-
case
|
|
1448
|
-
|
|
1449
|
-
|
|
1605
|
+
case 14:
|
|
1606
|
+
_context15.t0 = _context15.sent;
|
|
1607
|
+
_context15.next = 18;
|
|
1450
1608
|
break;
|
|
1451
|
-
case 16:
|
|
1452
|
-
_context13.t0 = false;
|
|
1453
1609
|
case 17:
|
|
1454
|
-
|
|
1610
|
+
_context15.t0 = false;
|
|
1611
|
+
case 18:
|
|
1612
|
+
shouldMerge = _context15.t0;
|
|
1455
1613
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
1456
1614
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
1457
1615
|
if (linked) {
|
|
@@ -1469,6 +1627,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1469
1627
|
unique_identification_number: targetUid
|
|
1470
1628
|
})
|
|
1471
1629
|
}));
|
|
1630
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1472
1631
|
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
1473
1632
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
1474
1633
|
unique_identification_number: targetUid
|
|
@@ -1483,20 +1642,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1483
1642
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1484
1643
|
}
|
|
1485
1644
|
this.applyDiscount();
|
|
1486
|
-
|
|
1645
|
+
_context15.next = 24;
|
|
1487
1646
|
return this.recalculateSummary({
|
|
1488
1647
|
createIfMissing: true
|
|
1489
1648
|
});
|
|
1490
|
-
case
|
|
1649
|
+
case 24:
|
|
1491
1650
|
this.persistTempOrder();
|
|
1492
|
-
return
|
|
1493
|
-
case
|
|
1651
|
+
return _context15.abrupt("return", tempOrder.products);
|
|
1652
|
+
case 26:
|
|
1494
1653
|
case "end":
|
|
1495
|
-
return
|
|
1654
|
+
return _context15.stop();
|
|
1496
1655
|
}
|
|
1497
|
-
},
|
|
1656
|
+
}, _callee15, this);
|
|
1498
1657
|
}));
|
|
1499
|
-
function addProductToOrder(
|
|
1658
|
+
function addProductToOrder(_x16, _x17) {
|
|
1500
1659
|
return _addProductToOrder.apply(this, arguments);
|
|
1501
1660
|
}
|
|
1502
1661
|
return addProductToOrder;
|
|
@@ -1521,15 +1680,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1521
1680
|
});
|
|
1522
1681
|
}
|
|
1523
1682
|
}, {
|
|
1524
|
-
key: "
|
|
1683
|
+
key: "updateOrderProduct",
|
|
1525
1684
|
value: function () {
|
|
1526
|
-
var
|
|
1685
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1527
1686
|
var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
|
|
1528
|
-
var product_id, product_variant_id, updates, unique_identification_number, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
|
|
1529
|
-
return _regeneratorRuntime().wrap(function
|
|
1530
|
-
while (1) switch (
|
|
1687
|
+
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, _normalizedProduct$me, _targetProduct$metada3, productUid, linked;
|
|
1688
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1689
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1531
1690
|
case 0:
|
|
1532
|
-
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
|
|
1691
|
+
product_id = params.product_id, product_variant_id = params.product_variant_id, updates = params.updates, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle, booking = params.booking;
|
|
1533
1692
|
tempOrder = this.ensureTempOrder();
|
|
1534
1693
|
identityLookup = {
|
|
1535
1694
|
product_id: product_id,
|
|
@@ -1537,16 +1696,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1537
1696
|
};
|
|
1538
1697
|
if (unique_identification_number !== undefined) {
|
|
1539
1698
|
identityLookup.unique_identification_number = unique_identification_number;
|
|
1699
|
+
if (identity_key === undefined) {
|
|
1700
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
if (identity_key !== undefined) {
|
|
1704
|
+
identityLookup.identity_key = identity_key;
|
|
1540
1705
|
}
|
|
1541
1706
|
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1542
1707
|
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1543
|
-
productIndex =
|
|
1708
|
+
productIndex = -1;
|
|
1709
|
+
if (unique_identification_number !== undefined) {
|
|
1710
|
+
targetUid = String(unique_identification_number);
|
|
1711
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1712
|
+
var _item$metadata;
|
|
1713
|
+
return String(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
if (productIndex === -1) {
|
|
1717
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1718
|
+
}
|
|
1544
1719
|
if (!(productIndex === -1)) {
|
|
1545
|
-
|
|
1720
|
+
_context16.next = 12;
|
|
1546
1721
|
break;
|
|
1547
1722
|
}
|
|
1548
1723
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
1549
|
-
case
|
|
1724
|
+
case 12:
|
|
1550
1725
|
targetProduct = tempOrder.products[productIndex];
|
|
1551
1726
|
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
|
|
1552
1727
|
product_id: product_id,
|
|
@@ -1574,57 +1749,218 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1574
1749
|
}
|
|
1575
1750
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
1576
1751
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
1577
|
-
|
|
1752
|
+
normalizedProduct = normalizeOrderProduct(nextProduct);
|
|
1753
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1754
|
+
if (booking) {
|
|
1755
|
+
productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
1756
|
+
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1757
|
+
unique_identification_number: productUid
|
|
1758
|
+
});
|
|
1759
|
+
linked = this.createLinkedProductAndBooking({
|
|
1760
|
+
product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1761
|
+
unique_identification_number: productUid
|
|
1762
|
+
}),
|
|
1763
|
+
booking: booking
|
|
1764
|
+
});
|
|
1765
|
+
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
1766
|
+
normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1767
|
+
booking_uid: linked.bookingUid,
|
|
1768
|
+
metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1769
|
+
booking_uid: linked.bookingUid,
|
|
1770
|
+
unique_identification_number: productUid
|
|
1771
|
+
})
|
|
1772
|
+
});
|
|
1773
|
+
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1774
|
+
}
|
|
1775
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1578
1776
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
1579
1777
|
this.applyDiscount();
|
|
1580
|
-
|
|
1778
|
+
_context16.next = 26;
|
|
1581
1779
|
return this.recalculateSummary({
|
|
1582
1780
|
createIfMissing: true
|
|
1583
1781
|
});
|
|
1584
|
-
case
|
|
1782
|
+
case 26:
|
|
1585
1783
|
this.persistTempOrder();
|
|
1586
|
-
return
|
|
1587
|
-
case
|
|
1784
|
+
return _context16.abrupt("return", tempOrder.products);
|
|
1785
|
+
case 28:
|
|
1588
1786
|
case "end":
|
|
1589
|
-
return
|
|
1787
|
+
return _context16.stop();
|
|
1590
1788
|
}
|
|
1591
|
-
},
|
|
1789
|
+
}, _callee16, this);
|
|
1790
|
+
}));
|
|
1791
|
+
function updateOrderProduct(_x18) {
|
|
1792
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
1793
|
+
}
|
|
1794
|
+
return updateOrderProduct;
|
|
1795
|
+
}()
|
|
1796
|
+
}, {
|
|
1797
|
+
key: "updateOrderProductQuantity",
|
|
1798
|
+
value: function () {
|
|
1799
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1800
|
+
var _targetProduct$metada4;
|
|
1801
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
1802
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1803
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1804
|
+
case 0:
|
|
1805
|
+
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_option_item = params.product_option_item, product_bundle = params.product_bundle;
|
|
1806
|
+
tempOrder = this.ensureTempOrder();
|
|
1807
|
+
identityLookup = {
|
|
1808
|
+
product_id: product_id,
|
|
1809
|
+
product_variant_id: product_variant_id
|
|
1810
|
+
};
|
|
1811
|
+
if (unique_identification_number !== undefined) {
|
|
1812
|
+
identityLookup.unique_identification_number = unique_identification_number;
|
|
1813
|
+
if (identity_key === undefined) {
|
|
1814
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
if (identity_key !== undefined) identityLookup.identity_key = identity_key;
|
|
1818
|
+
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1819
|
+
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1820
|
+
productIndex = -1;
|
|
1821
|
+
if (unique_identification_number !== undefined) {
|
|
1822
|
+
targetUid = String(unique_identification_number);
|
|
1823
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1824
|
+
var _item$metadata2;
|
|
1825
|
+
return String(((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
if (productIndex === -1) {
|
|
1829
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1830
|
+
}
|
|
1831
|
+
if (!(productIndex === -1)) {
|
|
1832
|
+
_context17.next = 12;
|
|
1833
|
+
break;
|
|
1834
|
+
}
|
|
1835
|
+
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
1836
|
+
case 12:
|
|
1837
|
+
targetProduct = tempOrder.products[productIndex];
|
|
1838
|
+
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
1839
|
+
num: getSafeProductNum(num),
|
|
1840
|
+
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
1841
|
+
unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
|
|
1842
|
+
})
|
|
1843
|
+
}));
|
|
1844
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1845
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1846
|
+
this.applyDiscount();
|
|
1847
|
+
_context17.next = 19;
|
|
1848
|
+
return this.recalculateSummary({
|
|
1849
|
+
createIfMissing: true
|
|
1850
|
+
});
|
|
1851
|
+
case 19:
|
|
1852
|
+
this.persistTempOrder();
|
|
1853
|
+
return _context17.abrupt("return", tempOrder.products);
|
|
1854
|
+
case 21:
|
|
1855
|
+
case "end":
|
|
1856
|
+
return _context17.stop();
|
|
1857
|
+
}
|
|
1858
|
+
}, _callee17, this);
|
|
1592
1859
|
}));
|
|
1593
|
-
function
|
|
1594
|
-
return
|
|
1860
|
+
function updateOrderProductQuantity(_x19) {
|
|
1861
|
+
return _updateOrderProductQuantity.apply(this, arguments);
|
|
1595
1862
|
}
|
|
1596
|
-
return
|
|
1863
|
+
return updateOrderProductQuantity;
|
|
1597
1864
|
}()
|
|
1865
|
+
}, {
|
|
1866
|
+
key: "updateOrderBooking",
|
|
1867
|
+
value: function updateOrderBooking(params) {
|
|
1868
|
+
var unique_identification_number = params.unique_identification_number,
|
|
1869
|
+
updates = params.updates;
|
|
1870
|
+
var tempOrder = this.ensureTempOrder();
|
|
1871
|
+
var bookingUid = String(unique_identification_number || '');
|
|
1872
|
+
var bookingIndex = this.findBookingIndexByUniqueIdentificationNumber(tempOrder, bookingUid);
|
|
1873
|
+
if (!bookingUid || bookingIndex === -1) {
|
|
1874
|
+
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
1875
|
+
}
|
|
1876
|
+
var targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
1877
|
+
var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
|
|
1878
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), {}, {
|
|
1879
|
+
unique_identification_number: bookingUid
|
|
1880
|
+
})
|
|
1881
|
+
});
|
|
1882
|
+
nextBooking.is_all = normalizeBookingIsAll(nextBooking);
|
|
1883
|
+
nextBooking.sub_type = normalizeBookingSubType(nextBooking);
|
|
1884
|
+
tempOrder.bookings[bookingIndex] = nextBooking;
|
|
1885
|
+
this.persistTempOrder();
|
|
1886
|
+
return tempOrder.bookings;
|
|
1887
|
+
}
|
|
1598
1888
|
}, {
|
|
1599
1889
|
key: "removeProductFromOrder",
|
|
1600
1890
|
value: function () {
|
|
1601
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1602
|
-
var tempOrder;
|
|
1603
|
-
return _regeneratorRuntime().wrap(function
|
|
1604
|
-
while (1) switch (
|
|
1891
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
|
|
1892
|
+
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
1893
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1894
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1605
1895
|
case 0:
|
|
1606
1896
|
tempOrder = this.ensureTempOrder();
|
|
1897
|
+
removedProducts = [];
|
|
1607
1898
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
1608
|
-
|
|
1899
|
+
var shouldRemove = isIdentityMatch(item, identity);
|
|
1900
|
+
if (shouldRemove) removedProducts.push(item);
|
|
1901
|
+
return !shouldRemove;
|
|
1609
1902
|
});
|
|
1903
|
+
for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
|
|
1904
|
+
product = _removedProducts[_i];
|
|
1905
|
+
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
1906
|
+
}
|
|
1610
1907
|
this.applyDiscount();
|
|
1611
|
-
|
|
1908
|
+
_context18.next = 7;
|
|
1612
1909
|
return this.recalculateSummary({
|
|
1613
1910
|
createIfMissing: true
|
|
1614
1911
|
});
|
|
1615
|
-
case 5:
|
|
1616
|
-
this.persistTempOrder();
|
|
1617
|
-
return _context15.abrupt("return", tempOrder.products);
|
|
1618
1912
|
case 7:
|
|
1913
|
+
this.persistTempOrder();
|
|
1914
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
1915
|
+
case 9:
|
|
1619
1916
|
case "end":
|
|
1620
|
-
return
|
|
1917
|
+
return _context18.stop();
|
|
1621
1918
|
}
|
|
1622
|
-
},
|
|
1919
|
+
}, _callee18, this);
|
|
1623
1920
|
}));
|
|
1624
|
-
function removeProductFromOrder(
|
|
1921
|
+
function removeProductFromOrder(_x20) {
|
|
1625
1922
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1626
1923
|
}
|
|
1627
1924
|
return removeProductFromOrder;
|
|
1925
|
+
}()
|
|
1926
|
+
/**
|
|
1927
|
+
* 仅清空购物车行(products / bookings),不重置整单。
|
|
1928
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
1929
|
+
*/
|
|
1930
|
+
}, {
|
|
1931
|
+
key: "clearOrderCartLines",
|
|
1932
|
+
value: (function () {
|
|
1933
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1934
|
+
var tempOrder;
|
|
1935
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1936
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1937
|
+
case 0:
|
|
1938
|
+
tempOrder = this.ensureTempOrder();
|
|
1939
|
+
tempOrder.products = [];
|
|
1940
|
+
tempOrder.bookings = [];
|
|
1941
|
+
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
1942
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
1943
|
+
productsByUid: {}
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
this.applyDiscount();
|
|
1947
|
+
_context19.next = 7;
|
|
1948
|
+
return this.recalculateSummary({
|
|
1949
|
+
createIfMissing: true
|
|
1950
|
+
});
|
|
1951
|
+
case 7:
|
|
1952
|
+
this.persistTempOrder();
|
|
1953
|
+
return _context19.abrupt("return", tempOrder);
|
|
1954
|
+
case 9:
|
|
1955
|
+
case "end":
|
|
1956
|
+
return _context19.stop();
|
|
1957
|
+
}
|
|
1958
|
+
}, _callee19, this);
|
|
1959
|
+
}));
|
|
1960
|
+
function clearOrderCartLines() {
|
|
1961
|
+
return _clearOrderCartLines.apply(this, arguments);
|
|
1962
|
+
}
|
|
1963
|
+
return clearOrderCartLines;
|
|
1628
1964
|
}() // ─── TempOrder: 提交 ───
|
|
1629
1965
|
/**
|
|
1630
1966
|
* 提交当前 Sales tempOrder。
|
|
@@ -1632,14 +1968,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
1968
|
* smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
|
|
1633
1969
|
* 应传 1,确保 /order/sales/checkout 返回打印所需数据。
|
|
1634
1970
|
*/
|
|
1971
|
+
)
|
|
1635
1972
|
}, {
|
|
1636
1973
|
key: "submitTempOrder",
|
|
1637
1974
|
value: function () {
|
|
1638
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1975
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1639
1976
|
var _params$cacheId, _this$otherParams;
|
|
1640
1977
|
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
1641
|
-
return _regeneratorRuntime().wrap(function
|
|
1642
|
-
while (1) switch (
|
|
1978
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1979
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1643
1980
|
case 0:
|
|
1644
1981
|
tempOrder = this.ensureTempOrder();
|
|
1645
1982
|
this.persistTempOrder();
|
|
@@ -1666,10 +2003,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1666
2003
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
1667
2004
|
enhance: enhancePayload
|
|
1668
2005
|
});
|
|
1669
|
-
|
|
2006
|
+
_context20.next = 10;
|
|
1670
2007
|
return this.saveDraft();
|
|
1671
2008
|
case 10:
|
|
1672
|
-
|
|
2009
|
+
_context20.prev = 10;
|
|
1673
2010
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
1674
2011
|
orderId: payload.order_id,
|
|
1675
2012
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -1677,62 +2014,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1677
2014
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
1678
2015
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
1679
2016
|
});
|
|
1680
|
-
|
|
2017
|
+
_context20.next = 14;
|
|
1681
2018
|
return this.submitSalesOrder({
|
|
1682
2019
|
query: payload
|
|
1683
2020
|
});
|
|
1684
2021
|
case 14:
|
|
1685
|
-
result =
|
|
1686
|
-
|
|
2022
|
+
result = _context20.sent;
|
|
2023
|
+
_context20.next = 27;
|
|
1687
2024
|
break;
|
|
1688
2025
|
case 17:
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
2026
|
+
_context20.prev = 17;
|
|
2027
|
+
_context20.t0 = _context20["catch"](10);
|
|
2028
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context20.t0);
|
|
1692
2029
|
if (!backendErrorResponse) {
|
|
1693
|
-
|
|
2030
|
+
_context20.next = 24;
|
|
1694
2031
|
break;
|
|
1695
2032
|
}
|
|
1696
2033
|
this.store.syncState = 'failed';
|
|
1697
2034
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
1698
|
-
return
|
|
2035
|
+
return _context20.abrupt("return", backendErrorResponse);
|
|
1699
2036
|
case 24:
|
|
1700
2037
|
this.store.syncState = 'failed';
|
|
1701
2038
|
this.logError('submitTempOrder failed', {
|
|
1702
|
-
error:
|
|
2039
|
+
error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
|
|
1703
2040
|
orderId: payload.order_id,
|
|
1704
2041
|
externalSaleNumber: payload.external_sale_number,
|
|
1705
2042
|
paymentStatus: payload.payment_status,
|
|
1706
2043
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
1707
2044
|
});
|
|
1708
|
-
throw
|
|
2045
|
+
throw _context20.t0;
|
|
1709
2046
|
case 27:
|
|
1710
2047
|
if (!this.isSubmitResponseRejected(result)) {
|
|
1711
|
-
|
|
2048
|
+
_context20.next = 31;
|
|
1712
2049
|
break;
|
|
1713
2050
|
}
|
|
1714
2051
|
this.store.syncState = 'failed';
|
|
1715
2052
|
this.logSubmitBackendRejected(result, payload);
|
|
1716
|
-
return
|
|
2053
|
+
return _context20.abrupt("return", result);
|
|
1717
2054
|
case 31:
|
|
1718
2055
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
1719
2056
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
1720
|
-
|
|
2057
|
+
_context20.next = 37;
|
|
1721
2058
|
break;
|
|
1722
2059
|
}
|
|
1723
2060
|
tempOrder.order_id = submittedOrderId;
|
|
1724
2061
|
resultRecord = result;
|
|
1725
|
-
|
|
2062
|
+
_context20.next = 37;
|
|
1726
2063
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
1727
2064
|
case 37:
|
|
1728
|
-
return
|
|
2065
|
+
return _context20.abrupt("return", result);
|
|
1729
2066
|
case 38:
|
|
1730
2067
|
case "end":
|
|
1731
|
-
return
|
|
2068
|
+
return _context20.stop();
|
|
1732
2069
|
}
|
|
1733
|
-
},
|
|
2070
|
+
}, _callee20, this, [[10, 17]]);
|
|
1734
2071
|
}));
|
|
1735
|
-
function submitTempOrder(
|
|
2072
|
+
function submitTempOrder(_x21) {
|
|
1736
2073
|
return _submitTempOrder.apply(this, arguments);
|
|
1737
2074
|
}
|
|
1738
2075
|
return submitTempOrder;
|
|
@@ -1740,25 +2077,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
2077
|
}, {
|
|
1741
2078
|
key: "markLocalOrderSynced",
|
|
1742
2079
|
value: function () {
|
|
1743
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2080
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderId, remoteOrder) {
|
|
1744
2081
|
var tempOrder;
|
|
1745
|
-
return _regeneratorRuntime().wrap(function
|
|
1746
|
-
while (1) switch (
|
|
2082
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2083
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1747
2084
|
case 0:
|
|
1748
2085
|
tempOrder = this.ensureTempOrder();
|
|
1749
2086
|
tempOrder.order_id = orderId;
|
|
1750
2087
|
this.store.lastOrderInfo = remoteOrder;
|
|
1751
2088
|
this.store.syncState = 'submitted';
|
|
1752
2089
|
this.persistTempOrder();
|
|
1753
|
-
|
|
2090
|
+
_context21.next = 7;
|
|
1754
2091
|
return this.saveDraft();
|
|
1755
2092
|
case 7:
|
|
1756
2093
|
case "end":
|
|
1757
|
-
return
|
|
2094
|
+
return _context21.stop();
|
|
1758
2095
|
}
|
|
1759
|
-
},
|
|
2096
|
+
}, _callee21, this);
|
|
1760
2097
|
}));
|
|
1761
|
-
function markLocalOrderSynced(
|
|
2098
|
+
function markLocalOrderSynced(_x22, _x23) {
|
|
1762
2099
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
1763
2100
|
}
|
|
1764
2101
|
return markLocalOrderSynced;
|
|
@@ -1782,10 +2119,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1782
2119
|
value: function extractSubmitErrorResponse(error) {
|
|
1783
2120
|
var _error$response,
|
|
1784
2121
|
_error$response2,
|
|
1785
|
-
|
|
2122
|
+
_this6 = this;
|
|
1786
2123
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
1787
2124
|
return candidates.find(function (candidate) {
|
|
1788
|
-
return
|
|
2125
|
+
return _this6.isSubmitErrorResponse(candidate);
|
|
1789
2126
|
}) || null;
|
|
1790
2127
|
}
|
|
1791
2128
|
}, {
|
|
@@ -1805,49 +2142,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1805
2142
|
}, {
|
|
1806
2143
|
key: "syncPaymentsToOrder",
|
|
1807
2144
|
value: function () {
|
|
1808
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1809
|
-
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, submitResult;
|
|
1810
|
-
return _regeneratorRuntime().wrap(function
|
|
1811
|
-
while (1) switch (
|
|
2145
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2146
|
+
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
|
|
2147
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2148
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1812
2149
|
case 0:
|
|
1813
2150
|
tempOrder = this.ensureTempOrder();
|
|
1814
2151
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
1815
|
-
tempOrder.payments = mappedPayments;
|
|
1816
|
-
if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
|
|
1817
|
-
this.persistTempOrder();
|
|
1818
|
-
_context18.next = 7;
|
|
1819
|
-
return this.saveDraft();
|
|
1820
|
-
case 7:
|
|
1821
2152
|
paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
1822
2153
|
targetAmount = this.getPaymentTargetAmount();
|
|
1823
2154
|
isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
1824
|
-
|
|
1825
|
-
|
|
2155
|
+
paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
|
|
2156
|
+
tempOrder.payments = mappedPayments;
|
|
2157
|
+
tempOrder.payment_status = paymentStatus;
|
|
2158
|
+
this.persistTempOrder();
|
|
2159
|
+
_context22.next = 11;
|
|
2160
|
+
return this.saveDraft();
|
|
2161
|
+
case 11:
|
|
2162
|
+
if (params.submitWhenPaid) {
|
|
2163
|
+
_context22.next = 13;
|
|
1826
2164
|
break;
|
|
1827
2165
|
}
|
|
1828
|
-
return
|
|
2166
|
+
return _context22.abrupt("return", {
|
|
1829
2167
|
isFullyPaid: isFullyPaid
|
|
1830
2168
|
});
|
|
1831
|
-
case
|
|
1832
|
-
|
|
2169
|
+
case 13:
|
|
2170
|
+
if (!(this.store.syncState === 'submitting')) {
|
|
2171
|
+
_context22.next = 15;
|
|
2172
|
+
break;
|
|
2173
|
+
}
|
|
2174
|
+
return _context22.abrupt("return", {
|
|
2175
|
+
isFullyPaid: isFullyPaid
|
|
2176
|
+
});
|
|
2177
|
+
case 15:
|
|
2178
|
+
this.store.syncState = 'submitting';
|
|
2179
|
+
_context22.next = 18;
|
|
1833
2180
|
return this.submitTempOrder({
|
|
1834
2181
|
payments: mappedPayments,
|
|
1835
|
-
paymentStatus:
|
|
1836
|
-
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2182
|
+
paymentStatus: paymentStatus,
|
|
2183
|
+
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2184
|
+
channel: params.channel
|
|
1837
2185
|
});
|
|
1838
|
-
case
|
|
1839
|
-
submitResult =
|
|
1840
|
-
return
|
|
2186
|
+
case 18:
|
|
2187
|
+
submitResult = _context22.sent;
|
|
2188
|
+
return _context22.abrupt("return", {
|
|
1841
2189
|
isFullyPaid: isFullyPaid,
|
|
1842
2190
|
submitResult: submitResult
|
|
1843
2191
|
});
|
|
1844
|
-
case
|
|
2192
|
+
case 20:
|
|
1845
2193
|
case "end":
|
|
1846
|
-
return
|
|
2194
|
+
return _context22.stop();
|
|
1847
2195
|
}
|
|
1848
|
-
},
|
|
2196
|
+
}, _callee22, this);
|
|
1849
2197
|
}));
|
|
1850
|
-
function syncPaymentsToOrder(
|
|
2198
|
+
function syncPaymentsToOrder(_x24) {
|
|
1851
2199
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
1852
2200
|
}
|
|
1853
2201
|
return syncPaymentsToOrder;
|
|
@@ -1936,11 +2284,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1936
2284
|
}, {
|
|
1937
2285
|
key: "submitOrder",
|
|
1938
2286
|
value: function () {
|
|
1939
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2287
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(order) {
|
|
1940
2288
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
1941
2289
|
var url, query, fetchUrl, params;
|
|
1942
|
-
return _regeneratorRuntime().wrap(function
|
|
1943
|
-
while (1) switch (
|
|
2290
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2291
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1944
2292
|
case 0:
|
|
1945
2293
|
this.logInfo('submitOrder called', {
|
|
1946
2294
|
url: order.url,
|
|
@@ -1960,14 +2308,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1960
2308
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
1961
2309
|
scheduleDate: params.schedule_date
|
|
1962
2310
|
});
|
|
1963
|
-
return
|
|
2311
|
+
return _context23.abrupt("return", this.request.post(fetchUrl, params));
|
|
1964
2312
|
case 6:
|
|
1965
2313
|
case "end":
|
|
1966
|
-
return
|
|
2314
|
+
return _context23.stop();
|
|
1967
2315
|
}
|
|
1968
|
-
},
|
|
2316
|
+
}, _callee23, this);
|
|
1969
2317
|
}));
|
|
1970
|
-
function submitOrder(
|
|
2318
|
+
function submitOrder(_x25) {
|
|
1971
2319
|
return _submitOrder.apply(this, arguments);
|
|
1972
2320
|
}
|
|
1973
2321
|
return submitOrder;
|
|
@@ -1975,13 +2323,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1975
2323
|
}, {
|
|
1976
2324
|
key: "cancelOrder",
|
|
1977
2325
|
value: function () {
|
|
1978
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2326
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1979
2327
|
var payload;
|
|
1980
|
-
return _regeneratorRuntime().wrap(function
|
|
1981
|
-
while (1) switch (
|
|
2328
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2329
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1982
2330
|
case 0:
|
|
1983
2331
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
1984
|
-
|
|
2332
|
+
_context24.next = 2;
|
|
1985
2333
|
break;
|
|
1986
2334
|
}
|
|
1987
2335
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -1997,16 +2345,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2345
|
method: 'PUT',
|
|
1998
2346
|
orderIdsCount: params.order_ids.length
|
|
1999
2347
|
});
|
|
2000
|
-
return
|
|
2348
|
+
return _context24.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
2001
2349
|
isShopApi: true
|
|
2002
2350
|
}));
|
|
2003
2351
|
case 5:
|
|
2004
2352
|
case "end":
|
|
2005
|
-
return
|
|
2353
|
+
return _context24.stop();
|
|
2006
2354
|
}
|
|
2007
|
-
},
|
|
2355
|
+
}, _callee24, this);
|
|
2008
2356
|
}));
|
|
2009
|
-
function cancelOrder(
|
|
2357
|
+
function cancelOrder(_x26) {
|
|
2010
2358
|
return _cancelOrder.apply(this, arguments);
|
|
2011
2359
|
}
|
|
2012
2360
|
return cancelOrder;
|
|
@@ -2014,19 +2362,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2362
|
}, {
|
|
2015
2363
|
key: "changeBookingStatus",
|
|
2016
2364
|
value: function () {
|
|
2017
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2365
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2018
2366
|
var url, payload;
|
|
2019
|
-
return _regeneratorRuntime().wrap(function
|
|
2020
|
-
while (1) switch (
|
|
2367
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2368
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2021
2369
|
case 0:
|
|
2022
2370
|
if (params.booking_id) {
|
|
2023
|
-
|
|
2371
|
+
_context25.next = 2;
|
|
2024
2372
|
break;
|
|
2025
2373
|
}
|
|
2026
2374
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
2027
2375
|
case 2:
|
|
2028
2376
|
if (params.appointment_status) {
|
|
2029
|
-
|
|
2377
|
+
_context25.next = 4;
|
|
2030
2378
|
break;
|
|
2031
2379
|
}
|
|
2032
2380
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -2041,16 +2389,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2041
2389
|
bookingId: params.booking_id,
|
|
2042
2390
|
appointmentStatus: params.appointment_status
|
|
2043
2391
|
});
|
|
2044
|
-
return
|
|
2392
|
+
return _context25.abrupt("return", this.request.put(url, payload, {
|
|
2045
2393
|
isShopApi: true
|
|
2046
2394
|
}));
|
|
2047
2395
|
case 8:
|
|
2048
2396
|
case "end":
|
|
2049
|
-
return
|
|
2397
|
+
return _context25.stop();
|
|
2050
2398
|
}
|
|
2051
|
-
},
|
|
2399
|
+
}, _callee25, this);
|
|
2052
2400
|
}));
|
|
2053
|
-
function changeBookingStatus(
|
|
2401
|
+
function changeBookingStatus(_x27) {
|
|
2054
2402
|
return _changeBookingStatus.apply(this, arguments);
|
|
2055
2403
|
}
|
|
2056
2404
|
return changeBookingStatus;
|
|
@@ -2068,11 +2416,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2068
2416
|
}, {
|
|
2069
2417
|
key: "createOrderByCheckout",
|
|
2070
2418
|
value: (function () {
|
|
2071
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2419
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2072
2420
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
2073
2421
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
2074
|
-
return _regeneratorRuntime().wrap(function
|
|
2075
|
-
while (1) switch (
|
|
2422
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2423
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2076
2424
|
case 0:
|
|
2077
2425
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
2078
2426
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -2106,7 +2454,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2106
2454
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
2107
2455
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
2108
2456
|
});
|
|
2109
|
-
|
|
2457
|
+
_context26.prev = 4;
|
|
2110
2458
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
2111
2459
|
orderData = _objectSpread({
|
|
2112
2460
|
sales_channel: 'my_pisel',
|
|
@@ -2170,10 +2518,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2170
2518
|
});
|
|
2171
2519
|
|
|
2172
2520
|
// 调用后端接口
|
|
2173
|
-
|
|
2521
|
+
_context26.next = 12;
|
|
2174
2522
|
return this.request.post('/order/checkout', orderData);
|
|
2175
2523
|
case 12:
|
|
2176
|
-
response =
|
|
2524
|
+
response = _context26.sent;
|
|
2177
2525
|
this.logInfo('Order API called successfully', {
|
|
2178
2526
|
response: response
|
|
2179
2527
|
});
|
|
@@ -2181,22 +2529,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2181
2529
|
success: !!response,
|
|
2182
2530
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
2183
2531
|
});
|
|
2184
|
-
return
|
|
2532
|
+
return _context26.abrupt("return", response);
|
|
2185
2533
|
case 18:
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
2534
|
+
_context26.prev = 18;
|
|
2535
|
+
_context26.t0 = _context26["catch"](4);
|
|
2536
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context26.t0);
|
|
2189
2537
|
this.logInfo('Order API called failed', {
|
|
2190
|
-
error:
|
|
2538
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
|
|
2191
2539
|
});
|
|
2192
|
-
throw
|
|
2540
|
+
throw _context26.t0;
|
|
2193
2541
|
case 23:
|
|
2194
2542
|
case "end":
|
|
2195
|
-
return
|
|
2543
|
+
return _context26.stop();
|
|
2196
2544
|
}
|
|
2197
|
-
},
|
|
2545
|
+
}, _callee26, this, [[4, 18]]);
|
|
2198
2546
|
}));
|
|
2199
|
-
function createOrderByCheckout(
|
|
2547
|
+
function createOrderByCheckout(_x28) {
|
|
2200
2548
|
return _createOrderByCheckout.apply(this, arguments);
|
|
2201
2549
|
}
|
|
2202
2550
|
return createOrderByCheckout;
|
|
@@ -2204,23 +2552,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2204
2552
|
}, {
|
|
2205
2553
|
key: "submitSalesOrder",
|
|
2206
2554
|
value: function () {
|
|
2207
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2555
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2208
2556
|
var url, query, fetchUrl;
|
|
2209
|
-
return _regeneratorRuntime().wrap(function
|
|
2210
|
-
while (1) switch (
|
|
2557
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2558
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2211
2559
|
case 0:
|
|
2212
2560
|
url = params.url, query = params.query;
|
|
2213
2561
|
fetchUrl = url || '/order/sales/checkout';
|
|
2214
|
-
return
|
|
2562
|
+
return _context27.abrupt("return", this.request.post(fetchUrl, query, {
|
|
2215
2563
|
customToast: function customToast() {}
|
|
2216
2564
|
}));
|
|
2217
2565
|
case 3:
|
|
2218
2566
|
case "end":
|
|
2219
|
-
return
|
|
2567
|
+
return _context27.stop();
|
|
2220
2568
|
}
|
|
2221
|
-
},
|
|
2569
|
+
}, _callee27, this);
|
|
2222
2570
|
}));
|
|
2223
|
-
function submitSalesOrder(
|
|
2571
|
+
function submitSalesOrder(_x29) {
|
|
2224
2572
|
return _submitSalesOrder.apply(this, arguments);
|
|
2225
2573
|
}
|
|
2226
2574
|
return submitSalesOrder;
|
|
@@ -2234,37 +2582,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2234
2582
|
}, {
|
|
2235
2583
|
key: "sendCustomerPayLink",
|
|
2236
2584
|
value: (function () {
|
|
2237
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2585
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2238
2586
|
var _params$emails;
|
|
2239
2587
|
var orderIds;
|
|
2240
|
-
return _regeneratorRuntime().wrap(function
|
|
2241
|
-
while (1) switch (
|
|
2588
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2589
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2242
2590
|
case 0:
|
|
2243
2591
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2244
2592
|
if (orderIds.length) {
|
|
2245
|
-
|
|
2593
|
+
_context28.next = 3;
|
|
2246
2594
|
break;
|
|
2247
2595
|
}
|
|
2248
2596
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
2249
2597
|
case 3:
|
|
2250
2598
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
2251
|
-
|
|
2599
|
+
_context28.next = 5;
|
|
2252
2600
|
break;
|
|
2253
2601
|
}
|
|
2254
2602
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
2255
2603
|
case 5:
|
|
2256
|
-
return
|
|
2604
|
+
return _context28.abrupt("return", this.request.post('/order/batch-email', {
|
|
2257
2605
|
order_ids: orderIds,
|
|
2258
2606
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
2259
2607
|
emails: params.emails
|
|
2260
2608
|
}));
|
|
2261
2609
|
case 6:
|
|
2262
2610
|
case "end":
|
|
2263
|
-
return
|
|
2611
|
+
return _context28.stop();
|
|
2264
2612
|
}
|
|
2265
|
-
},
|
|
2613
|
+
}, _callee28, this);
|
|
2266
2614
|
}));
|
|
2267
|
-
function sendCustomerPayLink(
|
|
2615
|
+
function sendCustomerPayLink(_x30) {
|
|
2268
2616
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
2269
2617
|
}
|
|
2270
2618
|
return sendCustomerPayLink;
|
|
@@ -2273,28 +2621,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2273
2621
|
}, {
|
|
2274
2622
|
key: "getOrderInfoByRemote",
|
|
2275
2623
|
value: function () {
|
|
2276
|
-
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2624
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(order_id) {
|
|
2277
2625
|
var res;
|
|
2278
|
-
return _regeneratorRuntime().wrap(function
|
|
2279
|
-
while (1) switch (
|
|
2626
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2627
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2280
2628
|
case 0:
|
|
2281
|
-
|
|
2629
|
+
_context29.next = 2;
|
|
2282
2630
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2283
2631
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
2284
2632
|
});
|
|
2285
2633
|
case 2:
|
|
2286
|
-
res =
|
|
2634
|
+
res = _context29.sent;
|
|
2287
2635
|
if (res.code === 200) {
|
|
2288
2636
|
this.store.lastOrderInfo = res.data;
|
|
2289
2637
|
}
|
|
2290
|
-
return
|
|
2638
|
+
return _context29.abrupt("return", res);
|
|
2291
2639
|
case 5:
|
|
2292
2640
|
case "end":
|
|
2293
|
-
return
|
|
2641
|
+
return _context29.stop();
|
|
2294
2642
|
}
|
|
2295
|
-
},
|
|
2643
|
+
}, _callee29, this);
|
|
2296
2644
|
}));
|
|
2297
|
-
function getOrderInfoByRemote(
|
|
2645
|
+
function getOrderInfoByRemote(_x31) {
|
|
2298
2646
|
return _getOrderInfoByRemote.apply(this, arguments);
|
|
2299
2647
|
}
|
|
2300
2648
|
return getOrderInfoByRemote;
|
|
@@ -2308,79 +2656,92 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2308
2656
|
}, {
|
|
2309
2657
|
key: "hydrateTempOrderFromRecord",
|
|
2310
2658
|
value: (function () {
|
|
2311
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2312
|
-
var
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
2659
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(record, options) {
|
|
2660
|
+
var raw, nextTempOrder;
|
|
2661
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2662
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2316
2663
|
case 0:
|
|
2317
2664
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
TEMP_ORDER_KEYS = ['order_id', 'external_sale_number', 'order_number', 'shop_order_number', 'shop_full_order_number', 'type', 'business_code', 'platform', 'sales_channel', 'order_sales_channel', 'status', 'payment_status', 'shipping_status', 'customer_id', 'customer_name', 'country_calling_code', 'phone', 'email', 'customer', 'is_price_include_tax', 'tax_title', 'tax_country_code', 'currency_code', 'currency_symbol', 'currency_format', 'is_deposit', 'deposit_amount', 'shop_discount', 'surcharge_fee', 'note', 'buzzer', 'delivery_type', 'table_number', 'schedule_date', 'created_at', 'request_unique_idempotency_token'];
|
|
2321
|
-
TEMP_ORDER_KEYS.forEach(function (key) {
|
|
2322
|
-
if (raw[key] !== undefined) {
|
|
2323
|
-
nextTempOrder[key] = raw[key];
|
|
2324
|
-
}
|
|
2665
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
2666
|
+
ensureIdentity: true
|
|
2325
2667
|
});
|
|
2326
|
-
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
2327
|
-
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
2328
|
-
nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
|
|
2329
|
-
return _this5.normalizeHydratedOrderProduct(p);
|
|
2330
|
-
}) : [];
|
|
2331
|
-
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
2332
|
-
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
2333
|
-
is_all: normalizeBookingIsAll(b || {}),
|
|
2334
|
-
sub_type: normalizeBookingSubType(b || {})
|
|
2335
|
-
});
|
|
2336
|
-
}) : [];
|
|
2337
|
-
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
2338
|
-
return _objectSpread({}, p || {});
|
|
2339
|
-
}) : [];
|
|
2340
|
-
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
2341
|
-
return _objectSpread({}, s || {});
|
|
2342
|
-
}) : [];
|
|
2343
|
-
nextTempOrder.discount_list = Array.isArray(raw.discount_list) ? raw.discount_list.map(function (d) {
|
|
2344
|
-
return _objectSpread({}, d || {});
|
|
2345
|
-
}) : [];
|
|
2346
|
-
nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
|
|
2347
|
-
return _objectSpread({}, f || {});
|
|
2348
|
-
}) : [];
|
|
2349
|
-
nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
|
|
2350
|
-
return _objectSpread({}, c || {});
|
|
2351
|
-
}) : [];
|
|
2352
|
-
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
2353
|
-
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
2354
|
-
productsByUid: raw._extend.productsByUid || {}
|
|
2355
|
-
}) : {
|
|
2356
|
-
productsByUid: {}
|
|
2357
|
-
};
|
|
2358
|
-
this.ensureExternalSaleNumber(nextTempOrder);
|
|
2359
2668
|
this.store.tempOrder = nextTempOrder;
|
|
2360
2669
|
this.store.summary = raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread(_objectSpread({}, createEmptySummary()), raw.summary) : createEmptySummary();
|
|
2361
2670
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
2362
2671
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
2363
|
-
|
|
2672
|
+
_context30.next = 8;
|
|
2364
2673
|
break;
|
|
2365
2674
|
}
|
|
2366
|
-
|
|
2675
|
+
_context30.next = 8;
|
|
2367
2676
|
return this.recalculateSummary({
|
|
2368
2677
|
createIfMissing: false
|
|
2369
2678
|
});
|
|
2370
|
-
case
|
|
2679
|
+
case 8:
|
|
2371
2680
|
this.persistTempOrder();
|
|
2372
|
-
return
|
|
2373
|
-
case
|
|
2681
|
+
return _context30.abrupt("return", nextTempOrder);
|
|
2682
|
+
case 10:
|
|
2374
2683
|
case "end":
|
|
2375
|
-
return
|
|
2684
|
+
return _context30.stop();
|
|
2376
2685
|
}
|
|
2377
|
-
},
|
|
2686
|
+
}, _callee30, this);
|
|
2378
2687
|
}));
|
|
2379
|
-
function hydrateTempOrderFromRecord(
|
|
2688
|
+
function hydrateTempOrderFromRecord(_x32, _x33) {
|
|
2380
2689
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
2381
2690
|
}
|
|
2382
2691
|
return hydrateTempOrderFromRecord;
|
|
2383
2692
|
}())
|
|
2693
|
+
}, {
|
|
2694
|
+
key: "normalizeTempOrderForRuntime",
|
|
2695
|
+
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
2696
|
+
var _this7 = this;
|
|
2697
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
2698
|
+
delete nextTempOrder.summary;
|
|
2699
|
+
delete nextTempOrder.lastOrderInfo;
|
|
2700
|
+
delete nextTempOrder.discount_list;
|
|
2701
|
+
delete nextTempOrder.shop_id;
|
|
2702
|
+
delete nextTempOrder.create_date;
|
|
2703
|
+
delete nextTempOrder.total_amount;
|
|
2704
|
+
delete nextTempOrder.expect_amount;
|
|
2705
|
+
delete nextTempOrder.paid_amount;
|
|
2706
|
+
delete nextTempOrder.shop_note;
|
|
2707
|
+
delete nextTempOrder.start_time;
|
|
2708
|
+
delete nextTempOrder.tax_fee;
|
|
2709
|
+
delete nextTempOrder.total_refund_amount;
|
|
2710
|
+
delete nextTempOrder.holder_id;
|
|
2711
|
+
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
2712
|
+
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
2713
|
+
nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
|
|
2714
|
+
return _this7.normalizeHydratedOrderProduct(p);
|
|
2715
|
+
}) : [];
|
|
2716
|
+
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
2717
|
+
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
2718
|
+
is_all: normalizeBookingIsAll(b || {}),
|
|
2719
|
+
sub_type: normalizeBookingSubType(b || {})
|
|
2720
|
+
});
|
|
2721
|
+
}) : [];
|
|
2722
|
+
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
2723
|
+
return _objectSpread({}, p || {});
|
|
2724
|
+
}) : [];
|
|
2725
|
+
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
2726
|
+
return _objectSpread({}, s || {});
|
|
2727
|
+
}) : [];
|
|
2728
|
+
nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
|
|
2729
|
+
return _objectSpread({}, f || {});
|
|
2730
|
+
}) : [];
|
|
2731
|
+
nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
|
|
2732
|
+
return _objectSpread({}, c || {});
|
|
2733
|
+
}) : [];
|
|
2734
|
+
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
2735
|
+
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
2736
|
+
productsByUid: raw._extend.productsByUid || {}
|
|
2737
|
+
}) : {
|
|
2738
|
+
productsByUid: {}
|
|
2739
|
+
};
|
|
2740
|
+
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
2741
|
+
this.ensureExternalSaleNumber(nextTempOrder);
|
|
2742
|
+
}
|
|
2743
|
+
return nextTempOrder;
|
|
2744
|
+
}
|
|
2384
2745
|
}, {
|
|
2385
2746
|
key: "normalizeHydratedOrderProduct",
|
|
2386
2747
|
value: function normalizeHydratedOrderProduct(product) {
|
|
@@ -2396,6 +2757,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2396
2757
|
row.metadata.unique_identification_number = createUuidV4();
|
|
2397
2758
|
}
|
|
2398
2759
|
var normalized = normalizeOrderProduct(row);
|
|
2760
|
+
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
2399
2761
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
2400
2762
|
metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
|
|
2401
2763
|
});
|
|
@@ -2411,25 +2773,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2411
2773
|
}, {
|
|
2412
2774
|
key: "getOrderInfo",
|
|
2413
2775
|
value: function () {
|
|
2414
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2776
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order_id) {
|
|
2415
2777
|
var res;
|
|
2416
|
-
return _regeneratorRuntime().wrap(function
|
|
2417
|
-
while (1) switch (
|
|
2778
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2779
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2418
2780
|
case 0:
|
|
2419
|
-
|
|
2781
|
+
_context31.next = 2;
|
|
2420
2782
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2421
2783
|
with: ['products', 'bookings']
|
|
2422
2784
|
});
|
|
2423
2785
|
case 2:
|
|
2424
|
-
res =
|
|
2425
|
-
return
|
|
2786
|
+
res = _context31.sent;
|
|
2787
|
+
return _context31.abrupt("return", res);
|
|
2426
2788
|
case 4:
|
|
2427
2789
|
case "end":
|
|
2428
|
-
return
|
|
2790
|
+
return _context31.stop();
|
|
2429
2791
|
}
|
|
2430
|
-
},
|
|
2792
|
+
}, _callee31, this);
|
|
2431
2793
|
}));
|
|
2432
|
-
function getOrderInfo(
|
|
2794
|
+
function getOrderInfo(_x34) {
|
|
2433
2795
|
return _getOrderInfo.apply(this, arguments);
|
|
2434
2796
|
}
|
|
2435
2797
|
return getOrderInfo;
|