@pisell/pisellos 2.2.171 → 2.2.172
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/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 +47 -16
- package/dist/modules/Order/index.js +743 -334
- package/dist/modules/Order/types.d.ts +57 -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 +23 -1
- package/dist/modules/Order/utils.js +139 -30
- 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 +9 -8
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +65 -7
- package/dist/solution/BaseSales/index.js +1066 -315
- package/dist/solution/BaseSales/types.d.ts +53 -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 +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +768 -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/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 +47 -16
- package/lib/modules/Order/index.js +389 -90
- package/lib/modules/Order/types.d.ts +57 -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 +23 -1
- package/lib/modules/Order/utils.js +145 -21
- 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 +8 -9
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +65 -7
- package/lib/solution/BaseSales/index.js +492 -20
- package/lib/solution/BaseSales/types.d.ts +53 -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 +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +341 -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 { generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList } 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";
|
|
@@ -56,6 +57,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
56
57
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
57
58
|
_defineProperty(_assertThisInitialized(_this), "orderHooks", void 0);
|
|
58
59
|
_defineProperty(_assertThisInitialized(_this), "otherParams", void 0);
|
|
60
|
+
/** 是否将 tempOrder 写入 localStorage;默认 true,SalesSdk 等内存态场景可关闭。 */
|
|
61
|
+
_defineProperty(_assertThisInitialized(_this), "enableTempOrderPersist", true);
|
|
59
62
|
return _this;
|
|
60
63
|
}
|
|
61
64
|
_createClass(OrderModule, [{
|
|
@@ -93,10 +96,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
93
96
|
this.rulesHooksOverride = (_otherParams$rules = otherParams.rules) === null || _otherParams$rules === void 0 ? void 0 : _otherParams$rules.hooks;
|
|
94
97
|
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
98
|
this.otherParams = otherParams;
|
|
99
|
+
this.enableTempOrderPersist = otherParams.enableTempOrderPersist !== false;
|
|
96
100
|
this.registerDiscountModules(options);
|
|
97
|
-
this.
|
|
101
|
+
if (this.enableTempOrderPersist) {
|
|
102
|
+
this.restoreTempOrderFromStorage();
|
|
103
|
+
}
|
|
98
104
|
this.logInfo('OrderModule initialized successfully');
|
|
99
|
-
case
|
|
105
|
+
case 22:
|
|
100
106
|
case "end":
|
|
101
107
|
return _context.stop();
|
|
102
108
|
}
|
|
@@ -196,29 +202,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
202
|
key: "loadDiscountConfig",
|
|
197
203
|
value: function () {
|
|
198
204
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
199
|
-
var _this$store$discount, _this$store$
|
|
200
|
-
var discountList, _this$store$discount2;
|
|
205
|
+
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
206
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3;
|
|
201
207
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
202
208
|
while (1) switch (_context2.prev = _context2.next) {
|
|
203
209
|
case 0:
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
|
|
211
|
+
_context2.next = 3;
|
|
212
|
+
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
|
|
206
213
|
customer_id: params.customerId,
|
|
207
|
-
action: params.action || 'create',
|
|
214
|
+
action: params.action || (orderId ? 'edit' : 'create'),
|
|
208
215
|
with_good_pass: 1,
|
|
209
216
|
with_discount_card: 1,
|
|
210
217
|
with_wallet_pass_holder: 1,
|
|
211
218
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
212
|
-
}
|
|
213
|
-
|
|
219
|
+
}, orderId ? {
|
|
220
|
+
order_id: orderId
|
|
221
|
+
} : {}));
|
|
222
|
+
case 3:
|
|
214
223
|
discountList = _context2.sent;
|
|
215
|
-
if (discountList) {
|
|
216
|
-
|
|
224
|
+
if (!discountList) {
|
|
225
|
+
_context2.next = 9;
|
|
226
|
+
break;
|
|
217
227
|
}
|
|
218
|
-
|
|
228
|
+
_context2.next = 7;
|
|
229
|
+
return (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.setOriginalDiscountList(discountList);
|
|
230
|
+
case 7:
|
|
231
|
+
_context2.next = 9;
|
|
232
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setDiscountList(discountList);
|
|
233
|
+
case 9:
|
|
234
|
+
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
235
|
this.applyDiscount();
|
|
220
236
|
}
|
|
221
|
-
|
|
237
|
+
return _context2.abrupt("return", this.getDiscountList());
|
|
238
|
+
case 11:
|
|
222
239
|
case "end":
|
|
223
240
|
return _context2.stop();
|
|
224
241
|
}
|
|
@@ -232,20 +249,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
232
249
|
}, {
|
|
233
250
|
key: "getDiscountList",
|
|
234
251
|
value: function getDiscountList() {
|
|
235
|
-
var _this$store$
|
|
236
|
-
return ((_this$store$
|
|
252
|
+
var _this$store$discount4;
|
|
253
|
+
return ((_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.getDiscountList()) || [];
|
|
237
254
|
}
|
|
238
255
|
}, {
|
|
239
256
|
key: "scanCode",
|
|
240
257
|
value: function () {
|
|
241
258
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
242
|
-
var _this$store$
|
|
243
|
-
var
|
|
259
|
+
var _this$store$discount5, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
|
|
260
|
+
var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount6;
|
|
244
261
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
245
262
|
while (1) switch (_context3.prev = _context3.next) {
|
|
246
263
|
case 0:
|
|
247
264
|
_context3.next = 2;
|
|
248
|
-
return (_this$store$
|
|
265
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.batchSearch(code, {
|
|
249
266
|
customerId: customerId
|
|
250
267
|
});
|
|
251
268
|
case 2:
|
|
@@ -254,36 +271,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
254
271
|
_context3.next = 5;
|
|
255
272
|
break;
|
|
256
273
|
}
|
|
257
|
-
_context3.t0 =
|
|
258
|
-
discountList: [],
|
|
259
|
-
unavailableReasonKey: null
|
|
260
|
-
};
|
|
274
|
+
_context3.t0 = [];
|
|
261
275
|
case 5:
|
|
262
|
-
|
|
263
|
-
resultDiscountList = resultDiscountWithReason.discountList, unavailableReasonKey = resultDiscountWithReason.unavailableReasonKey;
|
|
276
|
+
resultDiscountList = _context3.t0;
|
|
264
277
|
rulesModule = this.store.rules;
|
|
265
278
|
if (rulesModule) {
|
|
266
|
-
_context3.next =
|
|
279
|
+
_context3.next = 9;
|
|
267
280
|
break;
|
|
268
281
|
}
|
|
269
282
|
return _context3.abrupt("return", {
|
|
270
283
|
type: 'clientCalc',
|
|
271
284
|
isAvailable: false,
|
|
272
285
|
discountList: this.getDiscountList(),
|
|
286
|
+
scannedDiscountList: resultDiscountList,
|
|
273
287
|
unavailableReason: UnavailableReason.Unknown
|
|
274
288
|
});
|
|
275
|
-
case
|
|
289
|
+
case 9:
|
|
276
290
|
if (resultDiscountList.length) {
|
|
277
|
-
_context3.next =
|
|
291
|
+
_context3.next = 11;
|
|
278
292
|
break;
|
|
279
293
|
}
|
|
280
294
|
return _context3.abrupt("return", {
|
|
281
295
|
type: 'server',
|
|
282
296
|
isAvailable: false,
|
|
283
297
|
discountList: this.getDiscountList(),
|
|
284
|
-
|
|
298
|
+
scannedDiscountList: resultDiscountList
|
|
285
299
|
});
|
|
286
|
-
case
|
|
300
|
+
case 11:
|
|
287
301
|
withScanList = resultDiscountList.map(function (item) {
|
|
288
302
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
289
303
|
isScan: true
|
|
@@ -297,15 +311,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
297
311
|
return m.id === n.id;
|
|
298
312
|
});
|
|
299
313
|
}))) {
|
|
300
|
-
_context3.next =
|
|
314
|
+
_context3.next = 15;
|
|
301
315
|
break;
|
|
302
316
|
}
|
|
303
317
|
return _context3.abrupt("return", {
|
|
304
318
|
type: 'clientCalc',
|
|
305
319
|
isAvailable: true,
|
|
306
|
-
discountList: this.getDiscountList()
|
|
320
|
+
discountList: this.getDiscountList(),
|
|
321
|
+
scannedDiscountList: resultDiscountList
|
|
307
322
|
});
|
|
308
|
-
case
|
|
323
|
+
case 15:
|
|
309
324
|
tempOrder = this.store.tempOrder;
|
|
310
325
|
holders = tempOrder !== null && tempOrder !== void 0 && (_tempOrder$holder = tempOrder.holder) !== null && _tempOrder$holder !== void 0 && _tempOrder$holder.form_record_id ? [{
|
|
311
326
|
form_record_id: tempOrder.holder.form_record_id
|
|
@@ -322,16 +337,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
322
337
|
discountList: this.getDiscountList()
|
|
323
338
|
}, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
|
|
324
339
|
if (isAvailable && newDiscountList) {
|
|
325
|
-
(_this$store$
|
|
340
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
326
341
|
this.applyDiscount();
|
|
327
342
|
}
|
|
328
343
|
return _context3.abrupt("return", {
|
|
329
344
|
type: 'clientCalc',
|
|
330
345
|
isAvailable: isAvailable || false,
|
|
331
346
|
discountList: newDiscountList || this.getDiscountList(),
|
|
347
|
+
scannedDiscountList: resultDiscountList,
|
|
332
348
|
unavailableReason: unavailableReason
|
|
333
349
|
});
|
|
334
|
-
case
|
|
350
|
+
case 20:
|
|
335
351
|
case "end":
|
|
336
352
|
return _context3.stop();
|
|
337
353
|
}
|
|
@@ -345,15 +361,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
345
361
|
}, {
|
|
346
362
|
key: "applyDiscount",
|
|
347
363
|
value: function applyDiscount() {
|
|
348
|
-
var _this$store$
|
|
364
|
+
var _this$store$discount7, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
|
|
349
365
|
var tempOrder = this.store.tempOrder;
|
|
350
366
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
351
367
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
352
|
-
// appliedProductDetails / savedAmount
|
|
368
|
+
// appliedProductDetails / savedAmount 复位。
|
|
353
369
|
if (!tempOrder) return;
|
|
370
|
+
delete tempOrder.discount_list;
|
|
354
371
|
var rulesModule = this.store.rules;
|
|
355
372
|
if (!rulesModule) return;
|
|
356
|
-
var discountList = ((_this$store$
|
|
373
|
+
var discountList = ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
357
374
|
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
358
375
|
form_record_id: tempOrder.holder.form_record_id
|
|
359
376
|
}] : [];
|
|
@@ -365,15 +382,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
365
382
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
366
383
|
});
|
|
367
384
|
if (result !== null && result !== void 0 && result.productList) {
|
|
368
|
-
tempOrder.products = result.productList
|
|
385
|
+
tempOrder.products = (result.productList || []).map(function (product) {
|
|
386
|
+
return _objectSpread(_objectSpread({}, product), {}, {
|
|
387
|
+
discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(product.discount_list, product.num))
|
|
388
|
+
});
|
|
389
|
+
});
|
|
369
390
|
}
|
|
370
391
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
371
|
-
var _this$store$
|
|
392
|
+
var _this$store$discount8;
|
|
372
393
|
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
|
-
});
|
|
394
|
+
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(result.discountList);
|
|
377
395
|
}
|
|
378
396
|
}
|
|
379
397
|
|
|
@@ -423,9 +441,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
423
441
|
// 否则(v1 或无 metadata)→ 走 legacyDiscount 反推分支,基于新的 source + options
|
|
424
442
|
// 重算出含 option 的 main_product_*,并打上 price_schema_version: 2。
|
|
425
443
|
// 幂等:多次 restore 不会重复叠加 option/bundle。
|
|
426
|
-
|
|
444
|
+
var normalized = normalizeOrderProduct(row);
|
|
445
|
+
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
446
|
+
parsedData.products[i] = normalized;
|
|
427
447
|
}
|
|
428
448
|
}
|
|
449
|
+
delete parsedData.discount_list;
|
|
429
450
|
var parsedRecord = parsedData;
|
|
430
451
|
this.store.summary = parsedRecord.summary || createEmptySummary();
|
|
431
452
|
delete parsedData.summary;
|
|
@@ -446,9 +467,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
446
467
|
(_this$window = this.window) === null || _this$window === void 0 || (_this$window = _this$window.localStorage) === null || _this$window === void 0 || _this$window.removeItem(key);
|
|
447
468
|
}
|
|
448
469
|
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* 运行时切换 tempOrder localStorage 持久化。
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* orderModule.setEnableTempOrderPersist(false);
|
|
476
|
+
* orderModule.addProductToOrder(product); // 不会写入 localStorage
|
|
477
|
+
*/
|
|
478
|
+
}, {
|
|
479
|
+
key: "setEnableTempOrderPersist",
|
|
480
|
+
value: function setEnableTempOrderPersist(enabled) {
|
|
481
|
+
this.enableTempOrderPersist = enabled;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* 读取当前是否启用 tempOrder localStorage 持久化。
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* if (orderModule.isTempOrderPersistEnabled()) {
|
|
489
|
+
* orderModule.persistTempOrder();
|
|
490
|
+
* }
|
|
491
|
+
*/
|
|
492
|
+
}, {
|
|
493
|
+
key: "isTempOrderPersistEnabled",
|
|
494
|
+
value: function isTempOrderPersistEnabled() {
|
|
495
|
+
return this.enableTempOrderPersist;
|
|
496
|
+
}
|
|
449
497
|
}, {
|
|
450
498
|
key: "persistTempOrder",
|
|
451
499
|
value: function persistTempOrder() {
|
|
500
|
+
if (!this.enableTempOrderPersist) return;
|
|
452
501
|
var key = this.getTempOrderStorageKey();
|
|
453
502
|
if (!key || !this.store.tempOrder) return;
|
|
454
503
|
if (!this.window) return;
|
|
@@ -721,6 +770,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
721
770
|
}
|
|
722
771
|
return saveDraft;
|
|
723
772
|
}()
|
|
773
|
+
}, {
|
|
774
|
+
key: "saveDraftInBackground",
|
|
775
|
+
value: function saveDraftInBackground() {
|
|
776
|
+
void this.saveDraft();
|
|
777
|
+
}
|
|
724
778
|
}, {
|
|
725
779
|
key: "hydrateTempOrderFromLocalRecord",
|
|
726
780
|
value: function () {
|
|
@@ -812,11 +866,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
812
866
|
}, {
|
|
813
867
|
key: "restoreOrder",
|
|
814
868
|
value: function restoreOrder() {
|
|
869
|
+
var _this$store$discount9, _this$store$discount10;
|
|
815
870
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
816
871
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
817
872
|
this.store.tempOrder = freshTempOrder;
|
|
818
873
|
this.store.summary = createEmptySummary();
|
|
819
874
|
this.store.lastOrderInfo = undefined;
|
|
875
|
+
this.store.syncState = undefined;
|
|
876
|
+
void ((_this$store$discount9 = this.store.discount) === null || _this$store$discount9 === void 0 ? void 0 : _this$store$discount9.setOriginalDiscountList([]));
|
|
877
|
+
void ((_this$store$discount10 = this.store.discount) === null || _this$store$discount10 === void 0 ? void 0 : _this$store$discount10.setDiscountList([]));
|
|
820
878
|
this.persistTempOrder();
|
|
821
879
|
return freshTempOrder;
|
|
822
880
|
}
|
|
@@ -825,6 +883,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
825
883
|
value: function getTempOrder() {
|
|
826
884
|
return this.store.tempOrder;
|
|
827
885
|
}
|
|
886
|
+
}, {
|
|
887
|
+
key: "replaceTempOrder",
|
|
888
|
+
value: function () {
|
|
889
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
|
|
890
|
+
var nextTempOrder;
|
|
891
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
892
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
893
|
+
case 0:
|
|
894
|
+
if (isTempOrder(tempOrder)) {
|
|
895
|
+
_context9.next = 2;
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
throw new Error('无效的 tempOrder 数据');
|
|
899
|
+
case 2:
|
|
900
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
|
|
901
|
+
ensureIdentity: false
|
|
902
|
+
});
|
|
903
|
+
this.store.tempOrder = nextTempOrder;
|
|
904
|
+
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
905
|
+
_context9.next = 9;
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
_context9.next = 7;
|
|
909
|
+
return this.recalculateSummary({
|
|
910
|
+
createIfMissing: false
|
|
911
|
+
});
|
|
912
|
+
case 7:
|
|
913
|
+
_context9.next = 10;
|
|
914
|
+
break;
|
|
915
|
+
case 9:
|
|
916
|
+
this.store.summary = createEmptySummary();
|
|
917
|
+
case 10:
|
|
918
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
919
|
+
this.persistTempOrder();
|
|
920
|
+
}
|
|
921
|
+
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
922
|
+
_context9.next = 14;
|
|
923
|
+
break;
|
|
924
|
+
}
|
|
925
|
+
_context9.next = 14;
|
|
926
|
+
return this.saveDraft();
|
|
927
|
+
case 14:
|
|
928
|
+
return _context9.abrupt("return", nextTempOrder);
|
|
929
|
+
case 15:
|
|
930
|
+
case "end":
|
|
931
|
+
return _context9.stop();
|
|
932
|
+
}
|
|
933
|
+
}, _callee9, this);
|
|
934
|
+
}));
|
|
935
|
+
function replaceTempOrder(_x10, _x11) {
|
|
936
|
+
return _replaceTempOrder.apply(this, arguments);
|
|
937
|
+
}
|
|
938
|
+
return replaceTempOrder;
|
|
939
|
+
}()
|
|
828
940
|
}, {
|
|
829
941
|
key: "getOrderIdentity",
|
|
830
942
|
value: function getOrderIdentity() {
|
|
@@ -903,28 +1015,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
903
1015
|
}, {
|
|
904
1016
|
key: "addNewOrder",
|
|
905
1017
|
value: function () {
|
|
906
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1018
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
907
1019
|
var tempOrder;
|
|
908
|
-
return _regeneratorRuntime().wrap(function
|
|
909
|
-
while (1) switch (
|
|
1020
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1021
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
910
1022
|
case 0:
|
|
911
1023
|
tempOrder = this.ensureTempOrder();
|
|
912
1024
|
this.ensureExternalSaleNumber(tempOrder);
|
|
913
|
-
|
|
1025
|
+
_context10.next = 4;
|
|
914
1026
|
return this.recalculateSummary({
|
|
915
1027
|
createIfMissing: true
|
|
916
1028
|
});
|
|
917
1029
|
case 4:
|
|
918
1030
|
this.persistTempOrder();
|
|
919
|
-
|
|
1031
|
+
_context10.next = 7;
|
|
920
1032
|
return this.saveDraft();
|
|
921
1033
|
case 7:
|
|
922
|
-
return
|
|
1034
|
+
return _context10.abrupt("return", tempOrder);
|
|
923
1035
|
case 8:
|
|
924
1036
|
case "end":
|
|
925
|
-
return
|
|
1037
|
+
return _context10.stop();
|
|
926
1038
|
}
|
|
927
|
-
},
|
|
1039
|
+
}, _callee10, this);
|
|
928
1040
|
}));
|
|
929
1041
|
function addNewOrder() {
|
|
930
1042
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -1000,6 +1112,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1000
1112
|
})
|
|
1001
1113
|
};
|
|
1002
1114
|
}
|
|
1115
|
+
}, {
|
|
1116
|
+
key: "getBookingUniqueIdentificationNumber",
|
|
1117
|
+
value: function getBookingUniqueIdentificationNumber(booking) {
|
|
1118
|
+
var _booking$metadata;
|
|
1119
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
|
|
1120
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
1121
|
+
return String(uid);
|
|
1122
|
+
}
|
|
1123
|
+
}, {
|
|
1124
|
+
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
1125
|
+
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
1126
|
+
var _this3 = this;
|
|
1127
|
+
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
1128
|
+
return _this3.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
}, {
|
|
1132
|
+
key: "removeLinkedBookingsForProduct",
|
|
1133
|
+
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
1134
|
+
var _product$metadata,
|
|
1135
|
+
_product$metadata2,
|
|
1136
|
+
_this4 = this;
|
|
1137
|
+
var productUid = (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
1138
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid);
|
|
1139
|
+
if (!productUid && !bookingUid) return;
|
|
1140
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
1141
|
+
var currentBookingUid = _this4.getBookingUniqueIdentificationNumber(booking);
|
|
1142
|
+
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
1143
|
+
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
1144
|
+
return true;
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1003
1147
|
|
|
1004
1148
|
// ─── TempOrder: 金额汇总 ───
|
|
1005
1149
|
}, {
|
|
@@ -1011,23 +1155,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1011
1155
|
}, {
|
|
1012
1156
|
key: "recalculateSummary",
|
|
1013
1157
|
value: function () {
|
|
1014
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1158
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
1015
1159
|
var tempOrder, salesSummary, existedSummary, paidPaymentSummary, emptySummary, salesSummaryResult, summary;
|
|
1016
|
-
return _regeneratorRuntime().wrap(function
|
|
1017
|
-
while (1) switch (
|
|
1160
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1161
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1018
1162
|
case 0:
|
|
1019
1163
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1020
1164
|
if (tempOrder) {
|
|
1021
|
-
|
|
1165
|
+
_context11.next = 3;
|
|
1022
1166
|
break;
|
|
1023
1167
|
}
|
|
1024
|
-
return
|
|
1168
|
+
return _context11.abrupt("return", null);
|
|
1025
1169
|
case 3:
|
|
1026
1170
|
salesSummary = this.getSalesSummary();
|
|
1027
1171
|
existedSummary = this.store.summary || createEmptySummary();
|
|
1028
1172
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1029
1173
|
if (salesSummary) {
|
|
1030
|
-
|
|
1174
|
+
_context11.next = 11;
|
|
1031
1175
|
break;
|
|
1032
1176
|
}
|
|
1033
1177
|
emptySummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
|
|
@@ -1038,16 +1182,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1038
1182
|
});
|
|
1039
1183
|
this.store.summary = emptySummary;
|
|
1040
1184
|
tempOrder.surcharge_fee = emptySummary.surcharge_fee;
|
|
1041
|
-
return
|
|
1185
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1042
1186
|
case 11:
|
|
1043
|
-
|
|
1187
|
+
_context11.next = 13;
|
|
1044
1188
|
return salesSummary.getSummary({
|
|
1045
1189
|
products: tempOrder.products,
|
|
1046
1190
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1047
1191
|
shopDiscount: tempOrder.shop_discount
|
|
1048
1192
|
});
|
|
1049
1193
|
case 13:
|
|
1050
|
-
salesSummaryResult =
|
|
1194
|
+
salesSummaryResult = _context11.sent;
|
|
1051
1195
|
summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
1052
1196
|
total_refund_amount: existedSummary.total_refund_amount || '0.00',
|
|
1053
1197
|
customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
|
|
@@ -1065,14 +1209,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1065
1209
|
tempOrder.surcharges = summary.surcharges || [];
|
|
1066
1210
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
1067
1211
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
1068
|
-
return
|
|
1212
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1069
1213
|
case 23:
|
|
1070
1214
|
case "end":
|
|
1071
|
-
return
|
|
1215
|
+
return _context11.stop();
|
|
1072
1216
|
}
|
|
1073
|
-
},
|
|
1217
|
+
}, _callee11, this);
|
|
1074
1218
|
}));
|
|
1075
|
-
function recalculateSummary(
|
|
1219
|
+
function recalculateSummary(_x12) {
|
|
1076
1220
|
return _recalculateSummary.apply(this, arguments);
|
|
1077
1221
|
}
|
|
1078
1222
|
return recalculateSummary;
|
|
@@ -1080,30 +1224,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1080
1224
|
}, {
|
|
1081
1225
|
key: "getOrderSummary",
|
|
1082
1226
|
value: function () {
|
|
1083
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1227
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1084
1228
|
var summary;
|
|
1085
|
-
return _regeneratorRuntime().wrap(function
|
|
1086
|
-
while (1) switch (
|
|
1229
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1230
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1087
1231
|
case 0:
|
|
1088
|
-
|
|
1232
|
+
_context12.next = 2;
|
|
1089
1233
|
return this.recalculateSummary({
|
|
1090
1234
|
createIfMissing: true
|
|
1091
1235
|
});
|
|
1092
1236
|
case 2:
|
|
1093
|
-
summary =
|
|
1237
|
+
summary = _context12.sent;
|
|
1094
1238
|
if (summary) {
|
|
1095
|
-
|
|
1239
|
+
_context12.next = 5;
|
|
1096
1240
|
break;
|
|
1097
1241
|
}
|
|
1098
|
-
return
|
|
1242
|
+
return _context12.abrupt("return", createEmptySummary());
|
|
1099
1243
|
case 5:
|
|
1100
1244
|
this.persistTempOrder();
|
|
1101
|
-
return
|
|
1245
|
+
return _context12.abrupt("return", summary);
|
|
1102
1246
|
case 7:
|
|
1103
1247
|
case "end":
|
|
1104
|
-
return
|
|
1248
|
+
return _context12.stop();
|
|
1105
1249
|
}
|
|
1106
|
-
},
|
|
1250
|
+
}, _callee12, this);
|
|
1107
1251
|
}));
|
|
1108
1252
|
function getOrderSummary() {
|
|
1109
1253
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -1113,16 +1257,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1113
1257
|
}, {
|
|
1114
1258
|
key: "updateTempOrderNote",
|
|
1115
1259
|
value: function updateTempOrderNote(note) {
|
|
1260
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1116
1261
|
var tempOrder = this.ensureTempOrder();
|
|
1117
1262
|
tempOrder.note = String(note || '');
|
|
1118
1263
|
this.persistTempOrder();
|
|
1264
|
+
if (sync) {
|
|
1265
|
+
var orderId = tempOrder.order_id;
|
|
1266
|
+
if (!orderId) return tempOrder.note;
|
|
1267
|
+
return this.syncTempOrderNoteToRemote(orderId, tempOrder.note);
|
|
1268
|
+
}
|
|
1119
1269
|
return tempOrder.note;
|
|
1120
1270
|
}
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "syncTempOrderNoteToRemote",
|
|
1273
|
+
value: function () {
|
|
1274
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
|
|
1275
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1276
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1277
|
+
case 0:
|
|
1278
|
+
_context13.next = 2;
|
|
1279
|
+
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
1280
|
+
note: note
|
|
1281
|
+
});
|
|
1282
|
+
case 2:
|
|
1283
|
+
return _context13.abrupt("return", note);
|
|
1284
|
+
case 3:
|
|
1285
|
+
case "end":
|
|
1286
|
+
return _context13.stop();
|
|
1287
|
+
}
|
|
1288
|
+
}, _callee13, this);
|
|
1289
|
+
}));
|
|
1290
|
+
function syncTempOrderNoteToRemote(_x13, _x14) {
|
|
1291
|
+
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
1292
|
+
}
|
|
1293
|
+
return syncTempOrderNoteToRemote;
|
|
1294
|
+
}()
|
|
1121
1295
|
}, {
|
|
1122
1296
|
key: "getTempOrderNote",
|
|
1123
1297
|
value: function getTempOrderNote() {
|
|
1124
|
-
var _this$store$
|
|
1125
|
-
return ((_this$store$
|
|
1298
|
+
var _this$store$tempOrder3;
|
|
1299
|
+
return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
|
|
1126
1300
|
}
|
|
1127
1301
|
}, {
|
|
1128
1302
|
key: "updateTempOrderShopDiscount",
|
|
@@ -1149,25 +1323,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1149
1323
|
this.persistTempOrder();
|
|
1150
1324
|
return tempOrder.contacts_info;
|
|
1151
1325
|
}
|
|
1326
|
+
}, {
|
|
1327
|
+
key: "buildTempOrderCustomer",
|
|
1328
|
+
value: function buildTempOrderCustomer(params) {
|
|
1329
|
+
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;
|
|
1330
|
+
if (!params.customerId) return null;
|
|
1331
|
+
var source = params.source ? cloneDeep(params.source) : {};
|
|
1332
|
+
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;
|
|
1333
|
+
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;
|
|
1334
|
+
return _objectSpread(_objectSpread({}, source), {}, {
|
|
1335
|
+
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
1336
|
+
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
1337
|
+
name: String(name || ''),
|
|
1338
|
+
customer_name: String(customerName || ''),
|
|
1339
|
+
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),
|
|
1340
|
+
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
1341
|
+
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1152
1344
|
|
|
1153
1345
|
/**
|
|
1154
1346
|
* 更新当前 tempOrder 的客户协议字段。
|
|
1155
1347
|
*
|
|
1156
|
-
* PaymentModal
|
|
1348
|
+
* PaymentModal 只需要修改订单里的客户事实;如果外部还有客户模块需要同步,
|
|
1157
1349
|
* 应由调用方通过回调处理,不能把外部 UI 状态写进 tempOrder。
|
|
1158
1350
|
*/
|
|
1159
1351
|
}, {
|
|
1160
1352
|
key: "updateTempOrderCustomer",
|
|
1161
1353
|
value: function updateTempOrderCustomer(customer) {
|
|
1162
|
-
var
|
|
1354
|
+
var _ref15, _ref16, _customer$customer_id, _ref17, _ref18, _ref19, _customer$customer_na, _ref20, _customer$country_cal;
|
|
1163
1355
|
var tempOrder = this.ensureTempOrder();
|
|
1164
|
-
var customerId = (
|
|
1165
|
-
var customerName = (
|
|
1356
|
+
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;
|
|
1357
|
+
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
1358
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
1167
1359
|
tempOrder.customer_name = String(customerName || '');
|
|
1168
|
-
tempOrder.country_calling_code = String((
|
|
1360
|
+
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
1361
|
tempOrder.phone = String(customer.phone || '');
|
|
1170
1362
|
tempOrder.email = String(customer.email || '');
|
|
1363
|
+
tempOrder.customer = this.buildTempOrderCustomer({
|
|
1364
|
+
source: customer,
|
|
1365
|
+
customerId: tempOrder.customer_id,
|
|
1366
|
+
customerName: tempOrder.customer_name,
|
|
1367
|
+
countryCallingCode: tempOrder.country_calling_code,
|
|
1368
|
+
phone: tempOrder.phone,
|
|
1369
|
+
email: tempOrder.email
|
|
1370
|
+
});
|
|
1171
1371
|
this.persistTempOrder();
|
|
1172
1372
|
return {
|
|
1173
1373
|
customerId: tempOrder.customer_id,
|
|
@@ -1189,18 +1389,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1189
1389
|
tempOrder.country_calling_code = String(patch.country_calling_code || '');
|
|
1190
1390
|
tempOrder.phone = String(patch.phone || '');
|
|
1191
1391
|
tempOrder.email = String(patch.email || '');
|
|
1392
|
+
tempOrder.customer = this.buildTempOrderCustomer({
|
|
1393
|
+
source: snapshot || null,
|
|
1394
|
+
customerId: tempOrder.customer_id,
|
|
1395
|
+
customerName: tempOrder.customer_name,
|
|
1396
|
+
countryCallingCode: tempOrder.country_calling_code,
|
|
1397
|
+
phone: tempOrder.phone,
|
|
1398
|
+
email: tempOrder.email
|
|
1399
|
+
});
|
|
1192
1400
|
if (snapshot !== undefined) {
|
|
1193
1401
|
var extend = this.ensureExtend(tempOrder);
|
|
1194
1402
|
if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
|
|
1195
1403
|
}
|
|
1196
1404
|
this.persistTempOrder();
|
|
1405
|
+
this.saveDraftInBackground();
|
|
1197
1406
|
this.emitOrderCustomerChange();
|
|
1198
1407
|
}
|
|
1199
1408
|
}, {
|
|
1200
1409
|
key: "getOrderCustomer",
|
|
1201
1410
|
value: function getOrderCustomer() {
|
|
1202
1411
|
var tempOrder = this.store.tempOrder;
|
|
1203
|
-
if (!tempOrder || tempOrder.customer_id
|
|
1412
|
+
if (!tempOrder || !tempOrder.customer_id) {
|
|
1204
1413
|
return null;
|
|
1205
1414
|
}
|
|
1206
1415
|
return {
|
|
@@ -1214,8 +1423,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1214
1423
|
}, {
|
|
1215
1424
|
key: "getOrderCustomerSnapshot",
|
|
1216
1425
|
value: function getOrderCustomerSnapshot() {
|
|
1217
|
-
var _this$store$
|
|
1218
|
-
var snapshot = (_this$store$
|
|
1426
|
+
var _this$store$tempOrder4;
|
|
1427
|
+
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
1428
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
1220
1429
|
}
|
|
1221
1430
|
}, {
|
|
@@ -1227,8 +1436,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1227
1436
|
tempOrder.country_calling_code = '';
|
|
1228
1437
|
tempOrder.phone = '';
|
|
1229
1438
|
tempOrder.email = '';
|
|
1439
|
+
tempOrder.customer = null;
|
|
1230
1440
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
1231
1441
|
this.persistTempOrder();
|
|
1442
|
+
this.saveDraftInBackground();
|
|
1232
1443
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
1233
1444
|
}
|
|
1234
1445
|
}, {
|
|
@@ -1279,6 +1490,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1279
1490
|
}, {
|
|
1280
1491
|
key: "addOrderPayment",
|
|
1281
1492
|
value: function addOrderPayment(payment) {
|
|
1493
|
+
this.logInfo('addOrderPayment', {
|
|
1494
|
+
payment: payment
|
|
1495
|
+
});
|
|
1282
1496
|
var tempOrder = this.ensureTempOrder();
|
|
1283
1497
|
var mapped = mapPaymentItemsToOrderPayments([payment]);
|
|
1284
1498
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
@@ -1358,45 +1572,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1358
1572
|
}, {
|
|
1359
1573
|
key: "shouldMergeProductToOrder",
|
|
1360
1574
|
value: function () {
|
|
1361
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1575
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1362
1576
|
var _this$orderHooks;
|
|
1363
1577
|
var onBeforeMergeProductToOrder, result;
|
|
1364
|
-
return _regeneratorRuntime().wrap(function
|
|
1365
|
-
while (1) switch (
|
|
1578
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1579
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1366
1580
|
case 0:
|
|
1367
1581
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
1368
1582
|
if (onBeforeMergeProductToOrder) {
|
|
1369
|
-
|
|
1583
|
+
_context14.next = 3;
|
|
1370
1584
|
break;
|
|
1371
1585
|
}
|
|
1372
|
-
return
|
|
1586
|
+
return _context14.abrupt("return", true);
|
|
1373
1587
|
case 3:
|
|
1374
|
-
|
|
1588
|
+
_context14.next = 5;
|
|
1375
1589
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
1376
1590
|
defaultShouldMerge: true
|
|
1377
1591
|
}));
|
|
1378
1592
|
case 5:
|
|
1379
|
-
result =
|
|
1593
|
+
result = _context14.sent;
|
|
1380
1594
|
if (!(typeof result === 'boolean')) {
|
|
1381
|
-
|
|
1595
|
+
_context14.next = 8;
|
|
1382
1596
|
break;
|
|
1383
1597
|
}
|
|
1384
|
-
return
|
|
1598
|
+
return _context14.abrupt("return", result);
|
|
1385
1599
|
case 8:
|
|
1386
1600
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
1387
|
-
|
|
1601
|
+
_context14.next = 10;
|
|
1388
1602
|
break;
|
|
1389
1603
|
}
|
|
1390
|
-
return
|
|
1604
|
+
return _context14.abrupt("return", result.shouldMerge);
|
|
1391
1605
|
case 10:
|
|
1392
|
-
return
|
|
1606
|
+
return _context14.abrupt("return", true);
|
|
1393
1607
|
case 11:
|
|
1394
1608
|
case "end":
|
|
1395
|
-
return
|
|
1609
|
+
return _context14.stop();
|
|
1396
1610
|
}
|
|
1397
|
-
},
|
|
1611
|
+
}, _callee14, this);
|
|
1398
1612
|
}));
|
|
1399
|
-
function shouldMergeProductToOrder(
|
|
1613
|
+
function shouldMergeProductToOrder(_x15) {
|
|
1400
1614
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
1401
1615
|
}
|
|
1402
1616
|
return shouldMergeProductToOrder;
|
|
@@ -1404,11 +1618,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1404
1618
|
}, {
|
|
1405
1619
|
key: "addProductToOrder",
|
|
1406
1620
|
value: function () {
|
|
1407
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1408
|
-
var
|
|
1621
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
|
|
1622
|
+
var _this5 = this;
|
|
1409
1623
|
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 (
|
|
1624
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1625
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1412
1626
|
case 0:
|
|
1413
1627
|
tempOrder = this.ensureTempOrder();
|
|
1414
1628
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
@@ -1418,10 +1632,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1418
1632
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
1419
1633
|
incomingFingerprint = buildProductLineFingerprint(productToAdd.product_option_item, productToAdd.product_bundle);
|
|
1420
1634
|
normalizedIncoming = normalizeOrderProduct(productToAdd);
|
|
1635
|
+
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
1421
1636
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
1422
1637
|
shouldForceNewLine = !!booking;
|
|
1423
1638
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
1424
|
-
if (
|
|
1639
|
+
if (_this5.hasGoodPassDiscount(item)) return false;
|
|
1425
1640
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
1426
1641
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
1427
1642
|
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
@@ -1430,10 +1645,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1430
1645
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
1431
1646
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
|
|
1432
1647
|
if (!matchedProduct) {
|
|
1433
|
-
|
|
1648
|
+
_context15.next = 17;
|
|
1434
1649
|
break;
|
|
1435
1650
|
}
|
|
1436
|
-
|
|
1651
|
+
_context15.next = 14;
|
|
1437
1652
|
return this.shouldMergeProductToOrder({
|
|
1438
1653
|
incomingProduct: productToAdd,
|
|
1439
1654
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -1444,14 +1659,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1444
1659
|
tempOrder: tempOrder,
|
|
1445
1660
|
booking: booking
|
|
1446
1661
|
});
|
|
1447
|
-
case
|
|
1448
|
-
|
|
1449
|
-
|
|
1662
|
+
case 14:
|
|
1663
|
+
_context15.t0 = _context15.sent;
|
|
1664
|
+
_context15.next = 18;
|
|
1450
1665
|
break;
|
|
1451
|
-
case 16:
|
|
1452
|
-
_context13.t0 = false;
|
|
1453
1666
|
case 17:
|
|
1454
|
-
|
|
1667
|
+
_context15.t0 = false;
|
|
1668
|
+
case 18:
|
|
1669
|
+
shouldMerge = _context15.t0;
|
|
1455
1670
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
1456
1671
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
1457
1672
|
if (linked) {
|
|
@@ -1469,6 +1684,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1469
1684
|
unique_identification_number: targetUid
|
|
1470
1685
|
})
|
|
1471
1686
|
}));
|
|
1687
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1472
1688
|
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
1473
1689
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
1474
1690
|
unique_identification_number: targetUid
|
|
@@ -1483,20 +1699,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1483
1699
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1484
1700
|
}
|
|
1485
1701
|
this.applyDiscount();
|
|
1486
|
-
|
|
1702
|
+
_context15.next = 24;
|
|
1487
1703
|
return this.recalculateSummary({
|
|
1488
1704
|
createIfMissing: true
|
|
1489
1705
|
});
|
|
1490
|
-
case
|
|
1706
|
+
case 24:
|
|
1491
1707
|
this.persistTempOrder();
|
|
1492
|
-
return
|
|
1493
|
-
case
|
|
1708
|
+
return _context15.abrupt("return", tempOrder.products);
|
|
1709
|
+
case 26:
|
|
1494
1710
|
case "end":
|
|
1495
|
-
return
|
|
1711
|
+
return _context15.stop();
|
|
1496
1712
|
}
|
|
1497
|
-
},
|
|
1713
|
+
}, _callee15, this);
|
|
1498
1714
|
}));
|
|
1499
|
-
function addProductToOrder(
|
|
1715
|
+
function addProductToOrder(_x16, _x17) {
|
|
1500
1716
|
return _addProductToOrder.apply(this, arguments);
|
|
1501
1717
|
}
|
|
1502
1718
|
return addProductToOrder;
|
|
@@ -1521,15 +1737,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1521
1737
|
});
|
|
1522
1738
|
}
|
|
1523
1739
|
}, {
|
|
1524
|
-
key: "
|
|
1740
|
+
key: "updateOrderProduct",
|
|
1525
1741
|
value: function () {
|
|
1526
|
-
var
|
|
1742
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1527
1743
|
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 (
|
|
1744
|
+
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;
|
|
1745
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1746
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1531
1747
|
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;
|
|
1748
|
+
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
1749
|
tempOrder = this.ensureTempOrder();
|
|
1534
1750
|
identityLookup = {
|
|
1535
1751
|
product_id: product_id,
|
|
@@ -1537,16 +1753,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1537
1753
|
};
|
|
1538
1754
|
if (unique_identification_number !== undefined) {
|
|
1539
1755
|
identityLookup.unique_identification_number = unique_identification_number;
|
|
1756
|
+
if (identity_key === undefined) {
|
|
1757
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
if (identity_key !== undefined) {
|
|
1761
|
+
identityLookup.identity_key = identity_key;
|
|
1540
1762
|
}
|
|
1541
1763
|
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1542
1764
|
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1543
|
-
productIndex =
|
|
1765
|
+
productIndex = -1;
|
|
1766
|
+
if (unique_identification_number !== undefined) {
|
|
1767
|
+
targetUid = String(unique_identification_number);
|
|
1768
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1769
|
+
var _item$metadata;
|
|
1770
|
+
return String(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
if (productIndex === -1) {
|
|
1774
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1775
|
+
}
|
|
1544
1776
|
if (!(productIndex === -1)) {
|
|
1545
|
-
|
|
1777
|
+
_context16.next = 12;
|
|
1546
1778
|
break;
|
|
1547
1779
|
}
|
|
1548
1780
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
1549
|
-
case
|
|
1781
|
+
case 12:
|
|
1550
1782
|
targetProduct = tempOrder.products[productIndex];
|
|
1551
1783
|
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
|
|
1552
1784
|
product_id: product_id,
|
|
@@ -1574,57 +1806,218 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1574
1806
|
}
|
|
1575
1807
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
1576
1808
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
1577
|
-
|
|
1809
|
+
normalizedProduct = normalizeOrderProduct(nextProduct);
|
|
1810
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1811
|
+
if (booking) {
|
|
1812
|
+
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());
|
|
1813
|
+
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1814
|
+
unique_identification_number: productUid
|
|
1815
|
+
});
|
|
1816
|
+
linked = this.createLinkedProductAndBooking({
|
|
1817
|
+
product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1818
|
+
unique_identification_number: productUid
|
|
1819
|
+
}),
|
|
1820
|
+
booking: booking
|
|
1821
|
+
});
|
|
1822
|
+
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
1823
|
+
normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1824
|
+
booking_uid: linked.bookingUid,
|
|
1825
|
+
metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1826
|
+
booking_uid: linked.bookingUid,
|
|
1827
|
+
unique_identification_number: productUid
|
|
1828
|
+
})
|
|
1829
|
+
});
|
|
1830
|
+
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1831
|
+
}
|
|
1832
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1578
1833
|
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
1834
|
this.applyDiscount();
|
|
1580
|
-
|
|
1835
|
+
_context16.next = 26;
|
|
1581
1836
|
return this.recalculateSummary({
|
|
1582
1837
|
createIfMissing: true
|
|
1583
1838
|
});
|
|
1584
|
-
case
|
|
1839
|
+
case 26:
|
|
1585
1840
|
this.persistTempOrder();
|
|
1586
|
-
return
|
|
1587
|
-
case
|
|
1841
|
+
return _context16.abrupt("return", tempOrder.products);
|
|
1842
|
+
case 28:
|
|
1588
1843
|
case "end":
|
|
1589
|
-
return
|
|
1844
|
+
return _context16.stop();
|
|
1590
1845
|
}
|
|
1591
|
-
},
|
|
1846
|
+
}, _callee16, this);
|
|
1592
1847
|
}));
|
|
1593
|
-
function
|
|
1594
|
-
return
|
|
1848
|
+
function updateOrderProduct(_x18) {
|
|
1849
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
1595
1850
|
}
|
|
1596
|
-
return
|
|
1851
|
+
return updateOrderProduct;
|
|
1597
1852
|
}()
|
|
1853
|
+
}, {
|
|
1854
|
+
key: "updateOrderProductQuantity",
|
|
1855
|
+
value: function () {
|
|
1856
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1857
|
+
var _targetProduct$metada4;
|
|
1858
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
1859
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1860
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1861
|
+
case 0:
|
|
1862
|
+
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;
|
|
1863
|
+
tempOrder = this.ensureTempOrder();
|
|
1864
|
+
identityLookup = {
|
|
1865
|
+
product_id: product_id,
|
|
1866
|
+
product_variant_id: product_variant_id
|
|
1867
|
+
};
|
|
1868
|
+
if (unique_identification_number !== undefined) {
|
|
1869
|
+
identityLookup.unique_identification_number = unique_identification_number;
|
|
1870
|
+
if (identity_key === undefined) {
|
|
1871
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
if (identity_key !== undefined) identityLookup.identity_key = identity_key;
|
|
1875
|
+
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1876
|
+
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1877
|
+
productIndex = -1;
|
|
1878
|
+
if (unique_identification_number !== undefined) {
|
|
1879
|
+
targetUid = String(unique_identification_number);
|
|
1880
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1881
|
+
var _item$metadata2;
|
|
1882
|
+
return String(((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1883
|
+
});
|
|
1884
|
+
}
|
|
1885
|
+
if (productIndex === -1) {
|
|
1886
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1887
|
+
}
|
|
1888
|
+
if (!(productIndex === -1)) {
|
|
1889
|
+
_context17.next = 12;
|
|
1890
|
+
break;
|
|
1891
|
+
}
|
|
1892
|
+
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
1893
|
+
case 12:
|
|
1894
|
+
targetProduct = tempOrder.products[productIndex];
|
|
1895
|
+
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
1896
|
+
num: getSafeProductNum(num),
|
|
1897
|
+
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
1898
|
+
unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
|
|
1899
|
+
})
|
|
1900
|
+
}));
|
|
1901
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
1902
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1903
|
+
this.applyDiscount();
|
|
1904
|
+
_context17.next = 19;
|
|
1905
|
+
return this.recalculateSummary({
|
|
1906
|
+
createIfMissing: true
|
|
1907
|
+
});
|
|
1908
|
+
case 19:
|
|
1909
|
+
this.persistTempOrder();
|
|
1910
|
+
return _context17.abrupt("return", tempOrder.products);
|
|
1911
|
+
case 21:
|
|
1912
|
+
case "end":
|
|
1913
|
+
return _context17.stop();
|
|
1914
|
+
}
|
|
1915
|
+
}, _callee17, this);
|
|
1916
|
+
}));
|
|
1917
|
+
function updateOrderProductQuantity(_x19) {
|
|
1918
|
+
return _updateOrderProductQuantity.apply(this, arguments);
|
|
1919
|
+
}
|
|
1920
|
+
return updateOrderProductQuantity;
|
|
1921
|
+
}()
|
|
1922
|
+
}, {
|
|
1923
|
+
key: "updateOrderBooking",
|
|
1924
|
+
value: function updateOrderBooking(params) {
|
|
1925
|
+
var unique_identification_number = params.unique_identification_number,
|
|
1926
|
+
updates = params.updates;
|
|
1927
|
+
var tempOrder = this.ensureTempOrder();
|
|
1928
|
+
var bookingUid = String(unique_identification_number || '');
|
|
1929
|
+
var bookingIndex = this.findBookingIndexByUniqueIdentificationNumber(tempOrder, bookingUid);
|
|
1930
|
+
if (!bookingUid || bookingIndex === -1) {
|
|
1931
|
+
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
1932
|
+
}
|
|
1933
|
+
var targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
1934
|
+
var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
|
|
1935
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), {}, {
|
|
1936
|
+
unique_identification_number: bookingUid
|
|
1937
|
+
})
|
|
1938
|
+
});
|
|
1939
|
+
nextBooking.is_all = normalizeBookingIsAll(nextBooking);
|
|
1940
|
+
nextBooking.sub_type = normalizeBookingSubType(nextBooking);
|
|
1941
|
+
tempOrder.bookings[bookingIndex] = nextBooking;
|
|
1942
|
+
this.persistTempOrder();
|
|
1943
|
+
return tempOrder.bookings;
|
|
1944
|
+
}
|
|
1598
1945
|
}, {
|
|
1599
1946
|
key: "removeProductFromOrder",
|
|
1600
1947
|
value: function () {
|
|
1601
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1602
|
-
var tempOrder;
|
|
1603
|
-
return _regeneratorRuntime().wrap(function
|
|
1604
|
-
while (1) switch (
|
|
1948
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
|
|
1949
|
+
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
1950
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1951
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1605
1952
|
case 0:
|
|
1606
1953
|
tempOrder = this.ensureTempOrder();
|
|
1954
|
+
removedProducts = [];
|
|
1607
1955
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
1608
|
-
|
|
1956
|
+
var shouldRemove = isIdentityMatch(item, identity);
|
|
1957
|
+
if (shouldRemove) removedProducts.push(item);
|
|
1958
|
+
return !shouldRemove;
|
|
1609
1959
|
});
|
|
1960
|
+
for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
|
|
1961
|
+
product = _removedProducts[_i];
|
|
1962
|
+
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
1963
|
+
}
|
|
1610
1964
|
this.applyDiscount();
|
|
1611
|
-
|
|
1965
|
+
_context18.next = 7;
|
|
1612
1966
|
return this.recalculateSummary({
|
|
1613
1967
|
createIfMissing: true
|
|
1614
1968
|
});
|
|
1615
|
-
case 5:
|
|
1616
|
-
this.persistTempOrder();
|
|
1617
|
-
return _context15.abrupt("return", tempOrder.products);
|
|
1618
1969
|
case 7:
|
|
1970
|
+
this.persistTempOrder();
|
|
1971
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
1972
|
+
case 9:
|
|
1619
1973
|
case "end":
|
|
1620
|
-
return
|
|
1974
|
+
return _context18.stop();
|
|
1621
1975
|
}
|
|
1622
|
-
},
|
|
1976
|
+
}, _callee18, this);
|
|
1623
1977
|
}));
|
|
1624
|
-
function removeProductFromOrder(
|
|
1978
|
+
function removeProductFromOrder(_x20) {
|
|
1625
1979
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1626
1980
|
}
|
|
1627
1981
|
return removeProductFromOrder;
|
|
1982
|
+
}()
|
|
1983
|
+
/**
|
|
1984
|
+
* 仅清空购物车行(products / bookings),不重置整单。
|
|
1985
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
1986
|
+
*/
|
|
1987
|
+
}, {
|
|
1988
|
+
key: "clearOrderCartLines",
|
|
1989
|
+
value: (function () {
|
|
1990
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1991
|
+
var tempOrder;
|
|
1992
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1993
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1994
|
+
case 0:
|
|
1995
|
+
tempOrder = this.ensureTempOrder();
|
|
1996
|
+
tempOrder.products = [];
|
|
1997
|
+
tempOrder.bookings = [];
|
|
1998
|
+
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
1999
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
2000
|
+
productsByUid: {}
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
this.applyDiscount();
|
|
2004
|
+
_context19.next = 7;
|
|
2005
|
+
return this.recalculateSummary({
|
|
2006
|
+
createIfMissing: true
|
|
2007
|
+
});
|
|
2008
|
+
case 7:
|
|
2009
|
+
this.persistTempOrder();
|
|
2010
|
+
return _context19.abrupt("return", tempOrder);
|
|
2011
|
+
case 9:
|
|
2012
|
+
case "end":
|
|
2013
|
+
return _context19.stop();
|
|
2014
|
+
}
|
|
2015
|
+
}, _callee19, this);
|
|
2016
|
+
}));
|
|
2017
|
+
function clearOrderCartLines() {
|
|
2018
|
+
return _clearOrderCartLines.apply(this, arguments);
|
|
2019
|
+
}
|
|
2020
|
+
return clearOrderCartLines;
|
|
1628
2021
|
}() // ─── TempOrder: 提交 ───
|
|
1629
2022
|
/**
|
|
1630
2023
|
* 提交当前 Sales tempOrder。
|
|
@@ -1632,14 +2025,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
2025
|
* smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
|
|
1633
2026
|
* 应传 1,确保 /order/sales/checkout 返回打印所需数据。
|
|
1634
2027
|
*/
|
|
2028
|
+
)
|
|
1635
2029
|
}, {
|
|
1636
2030
|
key: "submitTempOrder",
|
|
1637
2031
|
value: function () {
|
|
1638
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2032
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1639
2033
|
var _params$cacheId, _this$otherParams;
|
|
1640
2034
|
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 (
|
|
2035
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
2036
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1643
2037
|
case 0:
|
|
1644
2038
|
tempOrder = this.ensureTempOrder();
|
|
1645
2039
|
this.persistTempOrder();
|
|
@@ -1666,10 +2060,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1666
2060
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
1667
2061
|
enhance: enhancePayload
|
|
1668
2062
|
});
|
|
1669
|
-
|
|
2063
|
+
_context20.next = 10;
|
|
1670
2064
|
return this.saveDraft();
|
|
1671
2065
|
case 10:
|
|
1672
|
-
|
|
2066
|
+
_context20.prev = 10;
|
|
1673
2067
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
1674
2068
|
orderId: payload.order_id,
|
|
1675
2069
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -1677,62 +2071,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1677
2071
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
1678
2072
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
1679
2073
|
});
|
|
1680
|
-
|
|
2074
|
+
_context20.next = 14;
|
|
1681
2075
|
return this.submitSalesOrder({
|
|
1682
2076
|
query: payload
|
|
1683
2077
|
});
|
|
1684
2078
|
case 14:
|
|
1685
|
-
result =
|
|
1686
|
-
|
|
2079
|
+
result = _context20.sent;
|
|
2080
|
+
_context20.next = 27;
|
|
1687
2081
|
break;
|
|
1688
2082
|
case 17:
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
2083
|
+
_context20.prev = 17;
|
|
2084
|
+
_context20.t0 = _context20["catch"](10);
|
|
2085
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context20.t0);
|
|
1692
2086
|
if (!backendErrorResponse) {
|
|
1693
|
-
|
|
2087
|
+
_context20.next = 24;
|
|
1694
2088
|
break;
|
|
1695
2089
|
}
|
|
1696
2090
|
this.store.syncState = 'failed';
|
|
1697
2091
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
1698
|
-
return
|
|
2092
|
+
return _context20.abrupt("return", backendErrorResponse);
|
|
1699
2093
|
case 24:
|
|
1700
2094
|
this.store.syncState = 'failed';
|
|
1701
2095
|
this.logError('submitTempOrder failed', {
|
|
1702
|
-
error:
|
|
2096
|
+
error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
|
|
1703
2097
|
orderId: payload.order_id,
|
|
1704
2098
|
externalSaleNumber: payload.external_sale_number,
|
|
1705
2099
|
paymentStatus: payload.payment_status,
|
|
1706
2100
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
1707
2101
|
});
|
|
1708
|
-
throw
|
|
2102
|
+
throw _context20.t0;
|
|
1709
2103
|
case 27:
|
|
1710
2104
|
if (!this.isSubmitResponseRejected(result)) {
|
|
1711
|
-
|
|
2105
|
+
_context20.next = 31;
|
|
1712
2106
|
break;
|
|
1713
2107
|
}
|
|
1714
2108
|
this.store.syncState = 'failed';
|
|
1715
2109
|
this.logSubmitBackendRejected(result, payload);
|
|
1716
|
-
return
|
|
2110
|
+
return _context20.abrupt("return", result);
|
|
1717
2111
|
case 31:
|
|
1718
2112
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
1719
2113
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
1720
|
-
|
|
2114
|
+
_context20.next = 37;
|
|
1721
2115
|
break;
|
|
1722
2116
|
}
|
|
1723
2117
|
tempOrder.order_id = submittedOrderId;
|
|
1724
2118
|
resultRecord = result;
|
|
1725
|
-
|
|
2119
|
+
_context20.next = 37;
|
|
1726
2120
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
1727
2121
|
case 37:
|
|
1728
|
-
return
|
|
2122
|
+
return _context20.abrupt("return", result);
|
|
1729
2123
|
case 38:
|
|
1730
2124
|
case "end":
|
|
1731
|
-
return
|
|
2125
|
+
return _context20.stop();
|
|
1732
2126
|
}
|
|
1733
|
-
},
|
|
2127
|
+
}, _callee20, this, [[10, 17]]);
|
|
1734
2128
|
}));
|
|
1735
|
-
function submitTempOrder(
|
|
2129
|
+
function submitTempOrder(_x21) {
|
|
1736
2130
|
return _submitTempOrder.apply(this, arguments);
|
|
1737
2131
|
}
|
|
1738
2132
|
return submitTempOrder;
|
|
@@ -1740,25 +2134,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1740
2134
|
}, {
|
|
1741
2135
|
key: "markLocalOrderSynced",
|
|
1742
2136
|
value: function () {
|
|
1743
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2137
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderId, remoteOrder) {
|
|
1744
2138
|
var tempOrder;
|
|
1745
|
-
return _regeneratorRuntime().wrap(function
|
|
1746
|
-
while (1) switch (
|
|
2139
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2140
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1747
2141
|
case 0:
|
|
1748
2142
|
tempOrder = this.ensureTempOrder();
|
|
1749
2143
|
tempOrder.order_id = orderId;
|
|
1750
2144
|
this.store.lastOrderInfo = remoteOrder;
|
|
1751
2145
|
this.store.syncState = 'submitted';
|
|
1752
2146
|
this.persistTempOrder();
|
|
1753
|
-
|
|
2147
|
+
_context21.next = 7;
|
|
1754
2148
|
return this.saveDraft();
|
|
1755
2149
|
case 7:
|
|
1756
2150
|
case "end":
|
|
1757
|
-
return
|
|
2151
|
+
return _context21.stop();
|
|
1758
2152
|
}
|
|
1759
|
-
},
|
|
2153
|
+
}, _callee21, this);
|
|
1760
2154
|
}));
|
|
1761
|
-
function markLocalOrderSynced(
|
|
2155
|
+
function markLocalOrderSynced(_x22, _x23) {
|
|
1762
2156
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
1763
2157
|
}
|
|
1764
2158
|
return markLocalOrderSynced;
|
|
@@ -1782,10 +2176,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1782
2176
|
value: function extractSubmitErrorResponse(error) {
|
|
1783
2177
|
var _error$response,
|
|
1784
2178
|
_error$response2,
|
|
1785
|
-
|
|
2179
|
+
_this6 = this;
|
|
1786
2180
|
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
2181
|
return candidates.find(function (candidate) {
|
|
1788
|
-
return
|
|
2182
|
+
return _this6.isSubmitErrorResponse(candidate);
|
|
1789
2183
|
}) || null;
|
|
1790
2184
|
}
|
|
1791
2185
|
}, {
|
|
@@ -1805,49 +2199,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1805
2199
|
}, {
|
|
1806
2200
|
key: "syncPaymentsToOrder",
|
|
1807
2201
|
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 (
|
|
2202
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
2203
|
+
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, paymentStatus, submitResult;
|
|
2204
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2205
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1812
2206
|
case 0:
|
|
1813
2207
|
tempOrder = this.ensureTempOrder();
|
|
1814
2208
|
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
2209
|
paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
1822
2210
|
targetAmount = this.getPaymentTargetAmount();
|
|
1823
2211
|
isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
1824
|
-
|
|
1825
|
-
|
|
2212
|
+
paymentStatus = isFullyPaid ? params.paymentStatus || 'paid' : 'partially_paid';
|
|
2213
|
+
tempOrder.payments = mappedPayments;
|
|
2214
|
+
tempOrder.payment_status = paymentStatus;
|
|
2215
|
+
this.persistTempOrder();
|
|
2216
|
+
_context22.next = 11;
|
|
2217
|
+
return this.saveDraft();
|
|
2218
|
+
case 11:
|
|
2219
|
+
if (params.submitWhenPaid) {
|
|
2220
|
+
_context22.next = 13;
|
|
1826
2221
|
break;
|
|
1827
2222
|
}
|
|
1828
|
-
return
|
|
2223
|
+
return _context22.abrupt("return", {
|
|
1829
2224
|
isFullyPaid: isFullyPaid
|
|
1830
2225
|
});
|
|
1831
|
-
case
|
|
1832
|
-
|
|
2226
|
+
case 13:
|
|
2227
|
+
if (!(this.store.syncState === 'submitting')) {
|
|
2228
|
+
_context22.next = 15;
|
|
2229
|
+
break;
|
|
2230
|
+
}
|
|
2231
|
+
return _context22.abrupt("return", {
|
|
2232
|
+
isFullyPaid: isFullyPaid
|
|
2233
|
+
});
|
|
2234
|
+
case 15:
|
|
2235
|
+
this.store.syncState = 'submitting';
|
|
2236
|
+
_context22.next = 18;
|
|
1833
2237
|
return this.submitTempOrder({
|
|
1834
2238
|
payments: mappedPayments,
|
|
1835
|
-
paymentStatus:
|
|
1836
|
-
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2239
|
+
paymentStatus: paymentStatus,
|
|
2240
|
+
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2241
|
+
channel: params.channel
|
|
1837
2242
|
});
|
|
1838
|
-
case
|
|
1839
|
-
submitResult =
|
|
1840
|
-
return
|
|
2243
|
+
case 18:
|
|
2244
|
+
submitResult = _context22.sent;
|
|
2245
|
+
return _context22.abrupt("return", {
|
|
1841
2246
|
isFullyPaid: isFullyPaid,
|
|
1842
2247
|
submitResult: submitResult
|
|
1843
2248
|
});
|
|
1844
|
-
case
|
|
2249
|
+
case 20:
|
|
1845
2250
|
case "end":
|
|
1846
|
-
return
|
|
2251
|
+
return _context22.stop();
|
|
1847
2252
|
}
|
|
1848
|
-
},
|
|
2253
|
+
}, _callee22, this);
|
|
1849
2254
|
}));
|
|
1850
|
-
function syncPaymentsToOrder(
|
|
2255
|
+
function syncPaymentsToOrder(_x24) {
|
|
1851
2256
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
1852
2257
|
}
|
|
1853
2258
|
return syncPaymentsToOrder;
|
|
@@ -1936,11 +2341,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1936
2341
|
}, {
|
|
1937
2342
|
key: "submitOrder",
|
|
1938
2343
|
value: function () {
|
|
1939
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2344
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(order) {
|
|
1940
2345
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
1941
2346
|
var url, query, fetchUrl, params;
|
|
1942
|
-
return _regeneratorRuntime().wrap(function
|
|
1943
|
-
while (1) switch (
|
|
2347
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2348
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1944
2349
|
case 0:
|
|
1945
2350
|
this.logInfo('submitOrder called', {
|
|
1946
2351
|
url: order.url,
|
|
@@ -1960,14 +2365,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1960
2365
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
1961
2366
|
scheduleDate: params.schedule_date
|
|
1962
2367
|
});
|
|
1963
|
-
return
|
|
2368
|
+
return _context23.abrupt("return", this.request.post(fetchUrl, params));
|
|
1964
2369
|
case 6:
|
|
1965
2370
|
case "end":
|
|
1966
|
-
return
|
|
2371
|
+
return _context23.stop();
|
|
1967
2372
|
}
|
|
1968
|
-
},
|
|
2373
|
+
}, _callee23, this);
|
|
1969
2374
|
}));
|
|
1970
|
-
function submitOrder(
|
|
2375
|
+
function submitOrder(_x25) {
|
|
1971
2376
|
return _submitOrder.apply(this, arguments);
|
|
1972
2377
|
}
|
|
1973
2378
|
return submitOrder;
|
|
@@ -1975,13 +2380,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1975
2380
|
}, {
|
|
1976
2381
|
key: "cancelOrder",
|
|
1977
2382
|
value: function () {
|
|
1978
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2383
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1979
2384
|
var payload;
|
|
1980
|
-
return _regeneratorRuntime().wrap(function
|
|
1981
|
-
while (1) switch (
|
|
2385
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2386
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1982
2387
|
case 0:
|
|
1983
2388
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
1984
|
-
|
|
2389
|
+
_context24.next = 2;
|
|
1985
2390
|
break;
|
|
1986
2391
|
}
|
|
1987
2392
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -1997,16 +2402,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
2402
|
method: 'PUT',
|
|
1998
2403
|
orderIdsCount: params.order_ids.length
|
|
1999
2404
|
});
|
|
2000
|
-
return
|
|
2405
|
+
return _context24.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
2001
2406
|
isShopApi: true
|
|
2002
2407
|
}));
|
|
2003
2408
|
case 5:
|
|
2004
2409
|
case "end":
|
|
2005
|
-
return
|
|
2410
|
+
return _context24.stop();
|
|
2006
2411
|
}
|
|
2007
|
-
},
|
|
2412
|
+
}, _callee24, this);
|
|
2008
2413
|
}));
|
|
2009
|
-
function cancelOrder(
|
|
2414
|
+
function cancelOrder(_x26) {
|
|
2010
2415
|
return _cancelOrder.apply(this, arguments);
|
|
2011
2416
|
}
|
|
2012
2417
|
return cancelOrder;
|
|
@@ -2014,19 +2419,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2419
|
}, {
|
|
2015
2420
|
key: "changeBookingStatus",
|
|
2016
2421
|
value: function () {
|
|
2017
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2422
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2018
2423
|
var url, payload;
|
|
2019
|
-
return _regeneratorRuntime().wrap(function
|
|
2020
|
-
while (1) switch (
|
|
2424
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2425
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2021
2426
|
case 0:
|
|
2022
2427
|
if (params.booking_id) {
|
|
2023
|
-
|
|
2428
|
+
_context25.next = 2;
|
|
2024
2429
|
break;
|
|
2025
2430
|
}
|
|
2026
2431
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
2027
2432
|
case 2:
|
|
2028
2433
|
if (params.appointment_status) {
|
|
2029
|
-
|
|
2434
|
+
_context25.next = 4;
|
|
2030
2435
|
break;
|
|
2031
2436
|
}
|
|
2032
2437
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -2041,16 +2446,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2041
2446
|
bookingId: params.booking_id,
|
|
2042
2447
|
appointmentStatus: params.appointment_status
|
|
2043
2448
|
});
|
|
2044
|
-
return
|
|
2449
|
+
return _context25.abrupt("return", this.request.put(url, payload, {
|
|
2045
2450
|
isShopApi: true
|
|
2046
2451
|
}));
|
|
2047
2452
|
case 8:
|
|
2048
2453
|
case "end":
|
|
2049
|
-
return
|
|
2454
|
+
return _context25.stop();
|
|
2050
2455
|
}
|
|
2051
|
-
},
|
|
2456
|
+
}, _callee25, this);
|
|
2052
2457
|
}));
|
|
2053
|
-
function changeBookingStatus(
|
|
2458
|
+
function changeBookingStatus(_x27) {
|
|
2054
2459
|
return _changeBookingStatus.apply(this, arguments);
|
|
2055
2460
|
}
|
|
2056
2461
|
return changeBookingStatus;
|
|
@@ -2068,11 +2473,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2068
2473
|
}, {
|
|
2069
2474
|
key: "createOrderByCheckout",
|
|
2070
2475
|
value: (function () {
|
|
2071
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2476
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2072
2477
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
2073
2478
|
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 (
|
|
2479
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2480
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2076
2481
|
case 0:
|
|
2077
2482
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
2078
2483
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -2106,7 +2511,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2106
2511
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
2107
2512
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
2108
2513
|
});
|
|
2109
|
-
|
|
2514
|
+
_context26.prev = 4;
|
|
2110
2515
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
2111
2516
|
orderData = _objectSpread({
|
|
2112
2517
|
sales_channel: 'my_pisel',
|
|
@@ -2170,10 +2575,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2170
2575
|
});
|
|
2171
2576
|
|
|
2172
2577
|
// 调用后端接口
|
|
2173
|
-
|
|
2578
|
+
_context26.next = 12;
|
|
2174
2579
|
return this.request.post('/order/checkout', orderData);
|
|
2175
2580
|
case 12:
|
|
2176
|
-
response =
|
|
2581
|
+
response = _context26.sent;
|
|
2177
2582
|
this.logInfo('Order API called successfully', {
|
|
2178
2583
|
response: response
|
|
2179
2584
|
});
|
|
@@ -2181,22 +2586,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2181
2586
|
success: !!response,
|
|
2182
2587
|
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
2588
|
});
|
|
2184
|
-
return
|
|
2589
|
+
return _context26.abrupt("return", response);
|
|
2185
2590
|
case 18:
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
2591
|
+
_context26.prev = 18;
|
|
2592
|
+
_context26.t0 = _context26["catch"](4);
|
|
2593
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context26.t0);
|
|
2189
2594
|
this.logInfo('Order API called failed', {
|
|
2190
|
-
error:
|
|
2595
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
|
|
2191
2596
|
});
|
|
2192
|
-
throw
|
|
2597
|
+
throw _context26.t0;
|
|
2193
2598
|
case 23:
|
|
2194
2599
|
case "end":
|
|
2195
|
-
return
|
|
2600
|
+
return _context26.stop();
|
|
2196
2601
|
}
|
|
2197
|
-
},
|
|
2602
|
+
}, _callee26, this, [[4, 18]]);
|
|
2198
2603
|
}));
|
|
2199
|
-
function createOrderByCheckout(
|
|
2604
|
+
function createOrderByCheckout(_x28) {
|
|
2200
2605
|
return _createOrderByCheckout.apply(this, arguments);
|
|
2201
2606
|
}
|
|
2202
2607
|
return createOrderByCheckout;
|
|
@@ -2204,23 +2609,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2204
2609
|
}, {
|
|
2205
2610
|
key: "submitSalesOrder",
|
|
2206
2611
|
value: function () {
|
|
2207
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2612
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2208
2613
|
var url, query, fetchUrl;
|
|
2209
|
-
return _regeneratorRuntime().wrap(function
|
|
2210
|
-
while (1) switch (
|
|
2614
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2615
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2211
2616
|
case 0:
|
|
2212
2617
|
url = params.url, query = params.query;
|
|
2213
2618
|
fetchUrl = url || '/order/sales/checkout';
|
|
2214
|
-
return
|
|
2619
|
+
return _context27.abrupt("return", this.request.post(fetchUrl, query, {
|
|
2215
2620
|
customToast: function customToast() {}
|
|
2216
2621
|
}));
|
|
2217
2622
|
case 3:
|
|
2218
2623
|
case "end":
|
|
2219
|
-
return
|
|
2624
|
+
return _context27.stop();
|
|
2220
2625
|
}
|
|
2221
|
-
},
|
|
2626
|
+
}, _callee27, this);
|
|
2222
2627
|
}));
|
|
2223
|
-
function submitSalesOrder(
|
|
2628
|
+
function submitSalesOrder(_x29) {
|
|
2224
2629
|
return _submitSalesOrder.apply(this, arguments);
|
|
2225
2630
|
}
|
|
2226
2631
|
return submitSalesOrder;
|
|
@@ -2234,37 +2639,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2234
2639
|
}, {
|
|
2235
2640
|
key: "sendCustomerPayLink",
|
|
2236
2641
|
value: (function () {
|
|
2237
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2642
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2238
2643
|
var _params$emails;
|
|
2239
2644
|
var orderIds;
|
|
2240
|
-
return _regeneratorRuntime().wrap(function
|
|
2241
|
-
while (1) switch (
|
|
2645
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2646
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2242
2647
|
case 0:
|
|
2243
2648
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2244
2649
|
if (orderIds.length) {
|
|
2245
|
-
|
|
2650
|
+
_context28.next = 3;
|
|
2246
2651
|
break;
|
|
2247
2652
|
}
|
|
2248
2653
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
2249
2654
|
case 3:
|
|
2250
2655
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
2251
|
-
|
|
2656
|
+
_context28.next = 5;
|
|
2252
2657
|
break;
|
|
2253
2658
|
}
|
|
2254
2659
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
2255
2660
|
case 5:
|
|
2256
|
-
return
|
|
2661
|
+
return _context28.abrupt("return", this.request.post('/order/batch-email', {
|
|
2257
2662
|
order_ids: orderIds,
|
|
2258
2663
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
2259
2664
|
emails: params.emails
|
|
2260
2665
|
}));
|
|
2261
2666
|
case 6:
|
|
2262
2667
|
case "end":
|
|
2263
|
-
return
|
|
2668
|
+
return _context28.stop();
|
|
2264
2669
|
}
|
|
2265
|
-
},
|
|
2670
|
+
}, _callee28, this);
|
|
2266
2671
|
}));
|
|
2267
|
-
function sendCustomerPayLink(
|
|
2672
|
+
function sendCustomerPayLink(_x30) {
|
|
2268
2673
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
2269
2674
|
}
|
|
2270
2675
|
return sendCustomerPayLink;
|
|
@@ -2273,28 +2678,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2273
2678
|
}, {
|
|
2274
2679
|
key: "getOrderInfoByRemote",
|
|
2275
2680
|
value: function () {
|
|
2276
|
-
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2681
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(order_id) {
|
|
2277
2682
|
var res;
|
|
2278
|
-
return _regeneratorRuntime().wrap(function
|
|
2279
|
-
while (1) switch (
|
|
2683
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2684
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2280
2685
|
case 0:
|
|
2281
|
-
|
|
2686
|
+
_context29.next = 2;
|
|
2282
2687
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2283
2688
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
2284
2689
|
});
|
|
2285
2690
|
case 2:
|
|
2286
|
-
res =
|
|
2691
|
+
res = _context29.sent;
|
|
2287
2692
|
if (res.code === 200) {
|
|
2288
2693
|
this.store.lastOrderInfo = res.data;
|
|
2289
2694
|
}
|
|
2290
|
-
return
|
|
2695
|
+
return _context29.abrupt("return", res);
|
|
2291
2696
|
case 5:
|
|
2292
2697
|
case "end":
|
|
2293
|
-
return
|
|
2698
|
+
return _context29.stop();
|
|
2294
2699
|
}
|
|
2295
|
-
},
|
|
2700
|
+
}, _callee29, this);
|
|
2296
2701
|
}));
|
|
2297
|
-
function getOrderInfoByRemote(
|
|
2702
|
+
function getOrderInfoByRemote(_x31) {
|
|
2298
2703
|
return _getOrderInfoByRemote.apply(this, arguments);
|
|
2299
2704
|
}
|
|
2300
2705
|
return getOrderInfoByRemote;
|
|
@@ -2308,79 +2713,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2308
2713
|
}, {
|
|
2309
2714
|
key: "hydrateTempOrderFromRecord",
|
|
2310
2715
|
value: (function () {
|
|
2311
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2312
|
-
var
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
2716
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(record, options) {
|
|
2717
|
+
var raw, nextTempOrder;
|
|
2718
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2719
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2316
2720
|
case 0:
|
|
2317
2721
|
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
|
-
}
|
|
2722
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
2723
|
+
ensureIdentity: true
|
|
2325
2724
|
});
|
|
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
2725
|
this.store.tempOrder = nextTempOrder;
|
|
2360
2726
|
this.store.summary = raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread(_objectSpread({}, createEmptySummary()), raw.summary) : createEmptySummary();
|
|
2361
2727
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
2362
2728
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
2363
|
-
|
|
2729
|
+
_context30.next = 8;
|
|
2364
2730
|
break;
|
|
2365
2731
|
}
|
|
2366
|
-
|
|
2732
|
+
_context30.next = 8;
|
|
2367
2733
|
return this.recalculateSummary({
|
|
2368
2734
|
createIfMissing: false
|
|
2369
2735
|
});
|
|
2370
|
-
case
|
|
2736
|
+
case 8:
|
|
2371
2737
|
this.persistTempOrder();
|
|
2372
|
-
return
|
|
2373
|
-
case
|
|
2738
|
+
return _context30.abrupt("return", nextTempOrder);
|
|
2739
|
+
case 10:
|
|
2374
2740
|
case "end":
|
|
2375
|
-
return
|
|
2741
|
+
return _context30.stop();
|
|
2376
2742
|
}
|
|
2377
|
-
},
|
|
2743
|
+
}, _callee30, this);
|
|
2378
2744
|
}));
|
|
2379
|
-
function hydrateTempOrderFromRecord(
|
|
2745
|
+
function hydrateTempOrderFromRecord(_x32, _x33) {
|
|
2380
2746
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
2381
2747
|
}
|
|
2382
2748
|
return hydrateTempOrderFromRecord;
|
|
2383
2749
|
}())
|
|
2750
|
+
}, {
|
|
2751
|
+
key: "normalizeTempOrderForRuntime",
|
|
2752
|
+
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
2753
|
+
var _this7 = this;
|
|
2754
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
2755
|
+
delete nextTempOrder.summary;
|
|
2756
|
+
delete nextTempOrder.lastOrderInfo;
|
|
2757
|
+
delete nextTempOrder.discount_list;
|
|
2758
|
+
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
2759
|
+
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
2760
|
+
nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
|
|
2761
|
+
return _this7.normalizeHydratedOrderProduct(p);
|
|
2762
|
+
}) : [];
|
|
2763
|
+
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
2764
|
+
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
2765
|
+
is_all: normalizeBookingIsAll(b || {}),
|
|
2766
|
+
sub_type: normalizeBookingSubType(b || {})
|
|
2767
|
+
});
|
|
2768
|
+
}) : [];
|
|
2769
|
+
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
2770
|
+
return _objectSpread({}, p || {});
|
|
2771
|
+
}) : [];
|
|
2772
|
+
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
2773
|
+
return _objectSpread({}, s || {});
|
|
2774
|
+
}) : [];
|
|
2775
|
+
nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
|
|
2776
|
+
return _objectSpread({}, f || {});
|
|
2777
|
+
}) : [];
|
|
2778
|
+
nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
|
|
2779
|
+
return _objectSpread({}, c || {});
|
|
2780
|
+
}) : [];
|
|
2781
|
+
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
2782
|
+
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
2783
|
+
productsByUid: raw._extend.productsByUid || {}
|
|
2784
|
+
}) : {
|
|
2785
|
+
productsByUid: {}
|
|
2786
|
+
};
|
|
2787
|
+
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
2788
|
+
this.ensureExternalSaleNumber(nextTempOrder);
|
|
2789
|
+
}
|
|
2790
|
+
return nextTempOrder;
|
|
2791
|
+
}
|
|
2384
2792
|
}, {
|
|
2385
2793
|
key: "normalizeHydratedOrderProduct",
|
|
2386
2794
|
value: function normalizeHydratedOrderProduct(product) {
|
|
@@ -2396,6 +2804,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2396
2804
|
row.metadata.unique_identification_number = createUuidV4();
|
|
2397
2805
|
}
|
|
2398
2806
|
var normalized = normalizeOrderProduct(row);
|
|
2807
|
+
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
2399
2808
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
2400
2809
|
metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
|
|
2401
2810
|
});
|
|
@@ -2411,25 +2820,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2411
2820
|
}, {
|
|
2412
2821
|
key: "getOrderInfo",
|
|
2413
2822
|
value: function () {
|
|
2414
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2823
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order_id) {
|
|
2415
2824
|
var res;
|
|
2416
|
-
return _regeneratorRuntime().wrap(function
|
|
2417
|
-
while (1) switch (
|
|
2825
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2826
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2418
2827
|
case 0:
|
|
2419
|
-
|
|
2828
|
+
_context31.next = 2;
|
|
2420
2829
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2421
2830
|
with: ['products', 'bookings']
|
|
2422
2831
|
});
|
|
2423
2832
|
case 2:
|
|
2424
|
-
res =
|
|
2425
|
-
return
|
|
2833
|
+
res = _context31.sent;
|
|
2834
|
+
return _context31.abrupt("return", res);
|
|
2426
2835
|
case 4:
|
|
2427
2836
|
case "end":
|
|
2428
|
-
return
|
|
2837
|
+
return _context31.stop();
|
|
2429
2838
|
}
|
|
2430
|
-
},
|
|
2839
|
+
}, _callee31, this);
|
|
2431
2840
|
}));
|
|
2432
|
-
function getOrderInfo(
|
|
2841
|
+
function getOrderInfo(_x34) {
|
|
2433
2842
|
return _getOrderInfo.apply(this, arguments);
|
|
2434
2843
|
}
|
|
2435
2844
|
return getOrderInfo;
|