@pisell/pisellos 2.2.163 → 2.2.165
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 +157 -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 +65 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -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.js +23 -22
- package/dist/modules/Discount/index.js +4 -3
- package/dist/modules/Order/index.d.ts +25 -7
- package/dist/modules/Order/index.js +608 -291
- package/dist/modules/Order/types.d.ts +46 -14
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +76 -23
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +46 -7
- package/dist/solution/BaseSales/index.js +928 -312
- package/dist/solution/BaseSales/types.d.ts +51 -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 +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +124 -1
- package/dist/solution/BookingTicket/index.js +488 -90
- 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 +111 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +334 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/dist/solution/VenueBooking/index.d.ts +4 -2
- 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 +174 -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 +65 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -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.js +8 -8
- package/lib/modules/Discount/index.js +5 -1
- package/lib/modules/Order/index.d.ts +25 -7
- package/lib/modules/Order/index.js +268 -72
- package/lib/modules/Order/types.d.ts +46 -14
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +66 -15
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/solution/BaseSales/index.d.ts +46 -7
- package/lib/solution/BaseSales/index.js +369 -17
- package/lib/solution/BaseSales/types.d.ts +51 -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 +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +124 -1
- package/lib/solution/BookingTicket/index.js +255 -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 +111 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +308 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/lib/solution/VenueBooking/index.d.ts +4 -2
- 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 +1 -1
|
@@ -196,29 +196,40 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
196
196
|
key: "loadDiscountConfig",
|
|
197
197
|
value: function () {
|
|
198
198
|
var _loadDiscountConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
199
|
-
var _this$store$discount, _this$store$
|
|
200
|
-
var discountList, _this$store$discount2;
|
|
199
|
+
var _this$store$tempOrder, _this$store$discount, _this$store$tempOrder2;
|
|
200
|
+
var orderId, discountList, _this$store$discount2, _this$store$discount3;
|
|
201
201
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
202
202
|
while (1) switch (_context2.prev = _context2.next) {
|
|
203
203
|
case 0:
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
orderId = params.orderId || ((_this$store$tempOrder = this.store.tempOrder) === null || _this$store$tempOrder === void 0 ? void 0 : _this$store$tempOrder.order_id) || undefined;
|
|
205
|
+
_context2.next = 3;
|
|
206
|
+
return (_this$store$discount = this.store.discount) === null || _this$store$discount === void 0 ? void 0 : _this$store$discount.loadPrepareConfig(_objectSpread({
|
|
206
207
|
customer_id: params.customerId,
|
|
207
|
-
action: params.action || 'create',
|
|
208
|
+
action: params.action || (orderId ? 'edit' : 'create'),
|
|
208
209
|
with_good_pass: 1,
|
|
209
210
|
with_discount_card: 1,
|
|
210
211
|
with_wallet_pass_holder: 1,
|
|
211
212
|
request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
212
|
-
}
|
|
213
|
-
|
|
213
|
+
}, orderId ? {
|
|
214
|
+
order_id: orderId
|
|
215
|
+
} : {}));
|
|
216
|
+
case 3:
|
|
214
217
|
discountList = _context2.sent;
|
|
215
|
-
if (discountList) {
|
|
216
|
-
|
|
218
|
+
if (!discountList) {
|
|
219
|
+
_context2.next = 9;
|
|
220
|
+
break;
|
|
217
221
|
}
|
|
218
|
-
|
|
222
|
+
_context2.next = 7;
|
|
223
|
+
return (_this$store$discount2 = this.store.discount) === null || _this$store$discount2 === void 0 ? void 0 : _this$store$discount2.setOriginalDiscountList(discountList);
|
|
224
|
+
case 7:
|
|
225
|
+
_context2.next = 9;
|
|
226
|
+
return (_this$store$discount3 = this.store.discount) === null || _this$store$discount3 === void 0 ? void 0 : _this$store$discount3.setDiscountList(discountList);
|
|
227
|
+
case 9:
|
|
228
|
+
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
229
|
this.applyDiscount();
|
|
220
230
|
}
|
|
221
|
-
|
|
231
|
+
return _context2.abrupt("return", this.getDiscountList());
|
|
232
|
+
case 11:
|
|
222
233
|
case "end":
|
|
223
234
|
return _context2.stop();
|
|
224
235
|
}
|
|
@@ -232,20 +243,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
232
243
|
}, {
|
|
233
244
|
key: "getDiscountList",
|
|
234
245
|
value: function getDiscountList() {
|
|
235
|
-
var _this$store$
|
|
236
|
-
return ((_this$store$
|
|
246
|
+
var _this$store$discount4;
|
|
247
|
+
return ((_this$store$discount4 = this.store.discount) === null || _this$store$discount4 === void 0 ? void 0 : _this$store$discount4.getDiscountList()) || [];
|
|
237
248
|
}
|
|
238
249
|
}, {
|
|
239
250
|
key: "scanCode",
|
|
240
251
|
value: function () {
|
|
241
252
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
242
|
-
var _this$store$
|
|
243
|
-
var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$
|
|
253
|
+
var _this$store$discount5, _tempOrder$holder, _this$store$summary, _tempOrder$holder2;
|
|
254
|
+
var resultDiscountList, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref, isAvailable, newDiscountList, unavailableReason, _this$store$discount6;
|
|
244
255
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
245
256
|
while (1) switch (_context3.prev = _context3.next) {
|
|
246
257
|
case 0:
|
|
247
258
|
_context3.next = 2;
|
|
248
|
-
return (_this$store$
|
|
259
|
+
return (_this$store$discount5 = this.store.discount) === null || _this$store$discount5 === void 0 ? void 0 : _this$store$discount5.batchSearch(code, {
|
|
249
260
|
customerId: customerId
|
|
250
261
|
});
|
|
251
262
|
case 2:
|
|
@@ -317,7 +328,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
317
328
|
discountList: this.getDiscountList()
|
|
318
329
|
}, isAvailable = _ref.isAvailable, newDiscountList = _ref.discountList, unavailableReason = _ref.unavailableReason;
|
|
319
330
|
if (isAvailable && newDiscountList) {
|
|
320
|
-
(_this$store$
|
|
331
|
+
(_this$store$discount6 = this.store.discount) === null || _this$store$discount6 === void 0 || _this$store$discount6.setDiscountList(newDiscountList);
|
|
321
332
|
this.applyDiscount();
|
|
322
333
|
}
|
|
323
334
|
return _context3.abrupt("return", {
|
|
@@ -340,7 +351,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
340
351
|
}, {
|
|
341
352
|
key: "applyDiscount",
|
|
342
353
|
value: function applyDiscount() {
|
|
343
|
-
var _this$store$
|
|
354
|
+
var _this$store$discount7, _tempOrder$holder3, _tempOrder$holder4, _this$store$summary2;
|
|
344
355
|
var tempOrder = this.store.tempOrder;
|
|
345
356
|
// 任意 products CRUD 后都应当重算 discount 状态;即使 products 为空,
|
|
346
357
|
// 也需要让 Rules.calcDiscount 把 DiscountModule 的 isSelected / isAvailable /
|
|
@@ -348,7 +359,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
348
359
|
if (!tempOrder) return;
|
|
349
360
|
var rulesModule = this.store.rules;
|
|
350
361
|
if (!rulesModule) return;
|
|
351
|
-
var discountList = ((_this$store$
|
|
362
|
+
var discountList = ((_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.getDiscountList()) || [];
|
|
352
363
|
var holders = (_tempOrder$holder3 = tempOrder.holder) !== null && _tempOrder$holder3 !== void 0 && _tempOrder$holder3.form_record_id ? [{
|
|
353
364
|
form_record_id: tempOrder.holder.form_record_id
|
|
354
365
|
}] : [];
|
|
@@ -363,9 +374,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
374
|
tempOrder.products = result.productList;
|
|
364
375
|
}
|
|
365
376
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
366
|
-
var _this$store$
|
|
377
|
+
var _this$store$discount8;
|
|
367
378
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
368
|
-
(_this$store$
|
|
379
|
+
(_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 || _this$store$discount8.setDiscountList(result.discountList);
|
|
369
380
|
tempOrder.discount_list = result.discountList.filter(function (d) {
|
|
370
381
|
return d.isSelected;
|
|
371
382
|
});
|
|
@@ -716,6 +727,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
716
727
|
}
|
|
717
728
|
return saveDraft;
|
|
718
729
|
}()
|
|
730
|
+
}, {
|
|
731
|
+
key: "saveDraftInBackground",
|
|
732
|
+
value: function saveDraftInBackground() {
|
|
733
|
+
void this.saveDraft();
|
|
734
|
+
}
|
|
719
735
|
}, {
|
|
720
736
|
key: "hydrateTempOrderFromLocalRecord",
|
|
721
737
|
value: function () {
|
|
@@ -820,6 +836,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
820
836
|
value: function getTempOrder() {
|
|
821
837
|
return this.store.tempOrder;
|
|
822
838
|
}
|
|
839
|
+
}, {
|
|
840
|
+
key: "replaceTempOrder",
|
|
841
|
+
value: function () {
|
|
842
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(tempOrder, options) {
|
|
843
|
+
var nextTempOrder;
|
|
844
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
845
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
846
|
+
case 0:
|
|
847
|
+
if (isTempOrder(tempOrder)) {
|
|
848
|
+
_context9.next = 2;
|
|
849
|
+
break;
|
|
850
|
+
}
|
|
851
|
+
throw new Error('无效的 tempOrder 数据');
|
|
852
|
+
case 2:
|
|
853
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
|
|
854
|
+
ensureIdentity: false
|
|
855
|
+
});
|
|
856
|
+
this.store.tempOrder = nextTempOrder;
|
|
857
|
+
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
858
|
+
_context9.next = 9;
|
|
859
|
+
break;
|
|
860
|
+
}
|
|
861
|
+
_context9.next = 7;
|
|
862
|
+
return this.recalculateSummary({
|
|
863
|
+
createIfMissing: false
|
|
864
|
+
});
|
|
865
|
+
case 7:
|
|
866
|
+
_context9.next = 10;
|
|
867
|
+
break;
|
|
868
|
+
case 9:
|
|
869
|
+
this.store.summary = createEmptySummary();
|
|
870
|
+
case 10:
|
|
871
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
872
|
+
this.persistTempOrder();
|
|
873
|
+
}
|
|
874
|
+
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
875
|
+
_context9.next = 14;
|
|
876
|
+
break;
|
|
877
|
+
}
|
|
878
|
+
_context9.next = 14;
|
|
879
|
+
return this.saveDraft();
|
|
880
|
+
case 14:
|
|
881
|
+
return _context9.abrupt("return", nextTempOrder);
|
|
882
|
+
case 15:
|
|
883
|
+
case "end":
|
|
884
|
+
return _context9.stop();
|
|
885
|
+
}
|
|
886
|
+
}, _callee9, this);
|
|
887
|
+
}));
|
|
888
|
+
function replaceTempOrder(_x10, _x11) {
|
|
889
|
+
return _replaceTempOrder.apply(this, arguments);
|
|
890
|
+
}
|
|
891
|
+
return replaceTempOrder;
|
|
892
|
+
}()
|
|
823
893
|
}, {
|
|
824
894
|
key: "getOrderIdentity",
|
|
825
895
|
value: function getOrderIdentity() {
|
|
@@ -898,28 +968,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
898
968
|
}, {
|
|
899
969
|
key: "addNewOrder",
|
|
900
970
|
value: function () {
|
|
901
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
971
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
902
972
|
var tempOrder;
|
|
903
|
-
return _regeneratorRuntime().wrap(function
|
|
904
|
-
while (1) switch (
|
|
973
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
974
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
905
975
|
case 0:
|
|
906
976
|
tempOrder = this.ensureTempOrder();
|
|
907
977
|
this.ensureExternalSaleNumber(tempOrder);
|
|
908
|
-
|
|
978
|
+
_context10.next = 4;
|
|
909
979
|
return this.recalculateSummary({
|
|
910
980
|
createIfMissing: true
|
|
911
981
|
});
|
|
912
982
|
case 4:
|
|
913
983
|
this.persistTempOrder();
|
|
914
|
-
|
|
984
|
+
_context10.next = 7;
|
|
915
985
|
return this.saveDraft();
|
|
916
986
|
case 7:
|
|
917
|
-
return
|
|
987
|
+
return _context10.abrupt("return", tempOrder);
|
|
918
988
|
case 8:
|
|
919
989
|
case "end":
|
|
920
|
-
return
|
|
990
|
+
return _context10.stop();
|
|
921
991
|
}
|
|
922
|
-
},
|
|
992
|
+
}, _callee10, this);
|
|
923
993
|
}));
|
|
924
994
|
function addNewOrder() {
|
|
925
995
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -995,6 +1065,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
995
1065
|
})
|
|
996
1066
|
};
|
|
997
1067
|
}
|
|
1068
|
+
}, {
|
|
1069
|
+
key: "getBookingUniqueIdentificationNumber",
|
|
1070
|
+
value: function getBookingUniqueIdentificationNumber(booking) {
|
|
1071
|
+
var _booking$metadata;
|
|
1072
|
+
var uid = booking === null || booking === void 0 || (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.unique_identification_number;
|
|
1073
|
+
if (uid === undefined || uid === null || uid === '') return null;
|
|
1074
|
+
return String(uid);
|
|
1075
|
+
}
|
|
1076
|
+
}, {
|
|
1077
|
+
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
1078
|
+
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
1079
|
+
var _this3 = this;
|
|
1080
|
+
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
1081
|
+
return _this3.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
}, {
|
|
1085
|
+
key: "removeLinkedBookingsForProduct",
|
|
1086
|
+
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
1087
|
+
var _product$metadata,
|
|
1088
|
+
_product$metadata2,
|
|
1089
|
+
_this4 = this;
|
|
1090
|
+
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);
|
|
1091
|
+
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);
|
|
1092
|
+
if (!productUid && !bookingUid) return;
|
|
1093
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
1094
|
+
var currentBookingUid = _this4.getBookingUniqueIdentificationNumber(booking);
|
|
1095
|
+
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
1096
|
+
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
1097
|
+
return true;
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
998
1100
|
|
|
999
1101
|
// ─── TempOrder: 金额汇总 ───
|
|
1000
1102
|
}, {
|
|
@@ -1006,23 +1108,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1006
1108
|
}, {
|
|
1007
1109
|
key: "recalculateSummary",
|
|
1008
1110
|
value: function () {
|
|
1009
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1111
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
1010
1112
|
var tempOrder, salesSummary, existedSummary, paidPaymentSummary, emptySummary, salesSummaryResult, summary;
|
|
1011
|
-
return _regeneratorRuntime().wrap(function
|
|
1012
|
-
while (1) switch (
|
|
1113
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1114
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1013
1115
|
case 0:
|
|
1014
1116
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1015
1117
|
if (tempOrder) {
|
|
1016
|
-
|
|
1118
|
+
_context11.next = 3;
|
|
1017
1119
|
break;
|
|
1018
1120
|
}
|
|
1019
|
-
return
|
|
1121
|
+
return _context11.abrupt("return", null);
|
|
1020
1122
|
case 3:
|
|
1021
1123
|
salesSummary = this.getSalesSummary();
|
|
1022
1124
|
existedSummary = this.store.summary || createEmptySummary();
|
|
1023
1125
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
1024
1126
|
if (salesSummary) {
|
|
1025
|
-
|
|
1127
|
+
_context11.next = 11;
|
|
1026
1128
|
break;
|
|
1027
1129
|
}
|
|
1028
1130
|
emptySummary = _objectSpread(_objectSpread({}, createEmptySummary()), {}, {
|
|
@@ -1033,16 +1135,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1033
1135
|
});
|
|
1034
1136
|
this.store.summary = emptySummary;
|
|
1035
1137
|
tempOrder.surcharge_fee = emptySummary.surcharge_fee;
|
|
1036
|
-
return
|
|
1138
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1037
1139
|
case 11:
|
|
1038
|
-
|
|
1140
|
+
_context11.next = 13;
|
|
1039
1141
|
return salesSummary.getSummary({
|
|
1040
1142
|
products: tempOrder.products,
|
|
1041
1143
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
1042
1144
|
shopDiscount: tempOrder.shop_discount
|
|
1043
1145
|
});
|
|
1044
1146
|
case 13:
|
|
1045
|
-
salesSummaryResult =
|
|
1147
|
+
salesSummaryResult = _context11.sent;
|
|
1046
1148
|
summary = _objectSpread(_objectSpread({}, salesSummaryResult), {}, {
|
|
1047
1149
|
total_refund_amount: existedSummary.total_refund_amount || '0.00',
|
|
1048
1150
|
customer_paid_amount: paidPaymentSummary.customerPaidAmount.toFixed(2),
|
|
@@ -1060,14 +1162,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
1162
|
tempOrder.surcharges = summary.surcharges || [];
|
|
1061
1163
|
tempOrder.deposit_amount = summary.deposit_amount || '0.00';
|
|
1062
1164
|
tempOrder.is_deposit = summary.deposit_amount !== '0.00' ? 1 : 0;
|
|
1063
|
-
return
|
|
1165
|
+
return _context11.abrupt("return", this.store.summary);
|
|
1064
1166
|
case 23:
|
|
1065
1167
|
case "end":
|
|
1066
|
-
return
|
|
1168
|
+
return _context11.stop();
|
|
1067
1169
|
}
|
|
1068
|
-
},
|
|
1170
|
+
}, _callee11, this);
|
|
1069
1171
|
}));
|
|
1070
|
-
function recalculateSummary(
|
|
1172
|
+
function recalculateSummary(_x12) {
|
|
1071
1173
|
return _recalculateSummary.apply(this, arguments);
|
|
1072
1174
|
}
|
|
1073
1175
|
return recalculateSummary;
|
|
@@ -1075,30 +1177,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1075
1177
|
}, {
|
|
1076
1178
|
key: "getOrderSummary",
|
|
1077
1179
|
value: function () {
|
|
1078
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1180
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1079
1181
|
var summary;
|
|
1080
|
-
return _regeneratorRuntime().wrap(function
|
|
1081
|
-
while (1) switch (
|
|
1182
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1183
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1082
1184
|
case 0:
|
|
1083
|
-
|
|
1185
|
+
_context12.next = 2;
|
|
1084
1186
|
return this.recalculateSummary({
|
|
1085
1187
|
createIfMissing: true
|
|
1086
1188
|
});
|
|
1087
1189
|
case 2:
|
|
1088
|
-
summary =
|
|
1190
|
+
summary = _context12.sent;
|
|
1089
1191
|
if (summary) {
|
|
1090
|
-
|
|
1192
|
+
_context12.next = 5;
|
|
1091
1193
|
break;
|
|
1092
1194
|
}
|
|
1093
|
-
return
|
|
1195
|
+
return _context12.abrupt("return", createEmptySummary());
|
|
1094
1196
|
case 5:
|
|
1095
1197
|
this.persistTempOrder();
|
|
1096
|
-
return
|
|
1198
|
+
return _context12.abrupt("return", summary);
|
|
1097
1199
|
case 7:
|
|
1098
1200
|
case "end":
|
|
1099
|
-
return
|
|
1201
|
+
return _context12.stop();
|
|
1100
1202
|
}
|
|
1101
|
-
},
|
|
1203
|
+
}, _callee12, this);
|
|
1102
1204
|
}));
|
|
1103
1205
|
function getOrderSummary() {
|
|
1104
1206
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -1108,16 +1210,46 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1108
1210
|
}, {
|
|
1109
1211
|
key: "updateTempOrderNote",
|
|
1110
1212
|
value: function updateTempOrderNote(note) {
|
|
1213
|
+
var sync = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1111
1214
|
var tempOrder = this.ensureTempOrder();
|
|
1112
1215
|
tempOrder.note = String(note || '');
|
|
1113
1216
|
this.persistTempOrder();
|
|
1217
|
+
if (sync) {
|
|
1218
|
+
var orderId = tempOrder.order_id;
|
|
1219
|
+
if (!orderId) return tempOrder.note;
|
|
1220
|
+
return this.syncTempOrderNoteToRemote(orderId, tempOrder.note);
|
|
1221
|
+
}
|
|
1114
1222
|
return tempOrder.note;
|
|
1115
1223
|
}
|
|
1224
|
+
}, {
|
|
1225
|
+
key: "syncTempOrderNoteToRemote",
|
|
1226
|
+
value: function () {
|
|
1227
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderId, note) {
|
|
1228
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1229
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1230
|
+
case 0:
|
|
1231
|
+
_context13.next = 2;
|
|
1232
|
+
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
1233
|
+
note: note
|
|
1234
|
+
});
|
|
1235
|
+
case 2:
|
|
1236
|
+
return _context13.abrupt("return", note);
|
|
1237
|
+
case 3:
|
|
1238
|
+
case "end":
|
|
1239
|
+
return _context13.stop();
|
|
1240
|
+
}
|
|
1241
|
+
}, _callee13, this);
|
|
1242
|
+
}));
|
|
1243
|
+
function syncTempOrderNoteToRemote(_x13, _x14) {
|
|
1244
|
+
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
1245
|
+
}
|
|
1246
|
+
return syncTempOrderNoteToRemote;
|
|
1247
|
+
}()
|
|
1116
1248
|
}, {
|
|
1117
1249
|
key: "getTempOrderNote",
|
|
1118
1250
|
value: function getTempOrderNote() {
|
|
1119
|
-
var _this$store$
|
|
1120
|
-
return ((_this$store$
|
|
1251
|
+
var _this$store$tempOrder3;
|
|
1252
|
+
return ((_this$store$tempOrder3 = this.store.tempOrder) === null || _this$store$tempOrder3 === void 0 ? void 0 : _this$store$tempOrder3.note) || '';
|
|
1121
1253
|
}
|
|
1122
1254
|
}, {
|
|
1123
1255
|
key: "updateTempOrderShopDiscount",
|
|
@@ -1189,13 +1321,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1189
1321
|
if (snapshot === null) delete extend.customerSnapshot;else extend.customerSnapshot = cloneDeep(snapshot);
|
|
1190
1322
|
}
|
|
1191
1323
|
this.persistTempOrder();
|
|
1324
|
+
this.saveDraftInBackground();
|
|
1192
1325
|
this.emitOrderCustomerChange();
|
|
1193
1326
|
}
|
|
1194
1327
|
}, {
|
|
1195
1328
|
key: "getOrderCustomer",
|
|
1196
1329
|
value: function getOrderCustomer() {
|
|
1197
1330
|
var tempOrder = this.store.tempOrder;
|
|
1198
|
-
if (!tempOrder || tempOrder.customer_id
|
|
1331
|
+
if (!tempOrder || !tempOrder.customer_id) {
|
|
1199
1332
|
return null;
|
|
1200
1333
|
}
|
|
1201
1334
|
return {
|
|
@@ -1209,21 +1342,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1209
1342
|
}, {
|
|
1210
1343
|
key: "getOrderCustomerSnapshot",
|
|
1211
1344
|
value: function getOrderCustomerSnapshot() {
|
|
1212
|
-
var _this$store$
|
|
1213
|
-
var snapshot = (_this$store$
|
|
1345
|
+
var _this$store$tempOrder4;
|
|
1346
|
+
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;
|
|
1214
1347
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
1215
1348
|
}
|
|
1216
1349
|
}, {
|
|
1217
1350
|
key: "clearOrderCustomer",
|
|
1218
1351
|
value: function clearOrderCustomer() {
|
|
1219
1352
|
var tempOrder = this.ensureTempOrder();
|
|
1220
|
-
tempOrder.customer_id =
|
|
1353
|
+
tempOrder.customer_id = 0;
|
|
1221
1354
|
tempOrder.customer_name = '';
|
|
1222
1355
|
tempOrder.country_calling_code = '';
|
|
1223
1356
|
tempOrder.phone = '';
|
|
1224
1357
|
tempOrder.email = '';
|
|
1225
1358
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
1226
1359
|
this.persistTempOrder();
|
|
1360
|
+
this.saveDraftInBackground();
|
|
1227
1361
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
1228
1362
|
}
|
|
1229
1363
|
}, {
|
|
@@ -1353,45 +1487,45 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1353
1487
|
}, {
|
|
1354
1488
|
key: "shouldMergeProductToOrder",
|
|
1355
1489
|
value: function () {
|
|
1356
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1490
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1357
1491
|
var _this$orderHooks;
|
|
1358
1492
|
var onBeforeMergeProductToOrder, result;
|
|
1359
|
-
return _regeneratorRuntime().wrap(function
|
|
1360
|
-
while (1) switch (
|
|
1493
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1494
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1361
1495
|
case 0:
|
|
1362
1496
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
1363
1497
|
if (onBeforeMergeProductToOrder) {
|
|
1364
|
-
|
|
1498
|
+
_context14.next = 3;
|
|
1365
1499
|
break;
|
|
1366
1500
|
}
|
|
1367
|
-
return
|
|
1501
|
+
return _context14.abrupt("return", true);
|
|
1368
1502
|
case 3:
|
|
1369
|
-
|
|
1503
|
+
_context14.next = 5;
|
|
1370
1504
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
1371
1505
|
defaultShouldMerge: true
|
|
1372
1506
|
}));
|
|
1373
1507
|
case 5:
|
|
1374
|
-
result =
|
|
1508
|
+
result = _context14.sent;
|
|
1375
1509
|
if (!(typeof result === 'boolean')) {
|
|
1376
|
-
|
|
1510
|
+
_context14.next = 8;
|
|
1377
1511
|
break;
|
|
1378
1512
|
}
|
|
1379
|
-
return
|
|
1513
|
+
return _context14.abrupt("return", result);
|
|
1380
1514
|
case 8:
|
|
1381
1515
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
1382
|
-
|
|
1516
|
+
_context14.next = 10;
|
|
1383
1517
|
break;
|
|
1384
1518
|
}
|
|
1385
|
-
return
|
|
1519
|
+
return _context14.abrupt("return", result.shouldMerge);
|
|
1386
1520
|
case 10:
|
|
1387
|
-
return
|
|
1521
|
+
return _context14.abrupt("return", true);
|
|
1388
1522
|
case 11:
|
|
1389
1523
|
case "end":
|
|
1390
|
-
return
|
|
1524
|
+
return _context14.stop();
|
|
1391
1525
|
}
|
|
1392
|
-
},
|
|
1526
|
+
}, _callee14, this);
|
|
1393
1527
|
}));
|
|
1394
|
-
function shouldMergeProductToOrder(
|
|
1528
|
+
function shouldMergeProductToOrder(_x15) {
|
|
1395
1529
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
1396
1530
|
}
|
|
1397
1531
|
return shouldMergeProductToOrder;
|
|
@@ -1399,11 +1533,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1399
1533
|
}, {
|
|
1400
1534
|
key: "addProductToOrder",
|
|
1401
1535
|
value: function () {
|
|
1402
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1403
|
-
var
|
|
1536
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(product, booking) {
|
|
1537
|
+
var _this5 = this;
|
|
1404
1538
|
var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
|
|
1405
|
-
return _regeneratorRuntime().wrap(function
|
|
1406
|
-
while (1) switch (
|
|
1539
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1540
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1407
1541
|
case 0:
|
|
1408
1542
|
tempOrder = this.ensureTempOrder();
|
|
1409
1543
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
@@ -1416,7 +1550,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1416
1550
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
1417
1551
|
shouldForceNewLine = !!booking;
|
|
1418
1552
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
1419
|
-
if (
|
|
1553
|
+
if (_this5.hasGoodPassDiscount(item)) return false;
|
|
1420
1554
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
1421
1555
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
1422
1556
|
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
@@ -1425,10 +1559,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1425
1559
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
1426
1560
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
|
|
1427
1561
|
if (!matchedProduct) {
|
|
1428
|
-
|
|
1562
|
+
_context15.next = 16;
|
|
1429
1563
|
break;
|
|
1430
1564
|
}
|
|
1431
|
-
|
|
1565
|
+
_context15.next = 13;
|
|
1432
1566
|
return this.shouldMergeProductToOrder({
|
|
1433
1567
|
incomingProduct: productToAdd,
|
|
1434
1568
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -1440,13 +1574,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1440
1574
|
booking: booking
|
|
1441
1575
|
});
|
|
1442
1576
|
case 13:
|
|
1443
|
-
|
|
1444
|
-
|
|
1577
|
+
_context15.t0 = _context15.sent;
|
|
1578
|
+
_context15.next = 17;
|
|
1445
1579
|
break;
|
|
1446
1580
|
case 16:
|
|
1447
|
-
|
|
1581
|
+
_context15.t0 = false;
|
|
1448
1582
|
case 17:
|
|
1449
|
-
shouldMerge =
|
|
1583
|
+
shouldMerge = _context15.t0;
|
|
1450
1584
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
1451
1585
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
1452
1586
|
if (linked) {
|
|
@@ -1478,20 +1612,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1478
1612
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1479
1613
|
}
|
|
1480
1614
|
this.applyDiscount();
|
|
1481
|
-
|
|
1615
|
+
_context15.next = 23;
|
|
1482
1616
|
return this.recalculateSummary({
|
|
1483
1617
|
createIfMissing: true
|
|
1484
1618
|
});
|
|
1485
1619
|
case 23:
|
|
1486
1620
|
this.persistTempOrder();
|
|
1487
|
-
return
|
|
1621
|
+
return _context15.abrupt("return", tempOrder.products);
|
|
1488
1622
|
case 25:
|
|
1489
1623
|
case "end":
|
|
1490
|
-
return
|
|
1624
|
+
return _context15.stop();
|
|
1491
1625
|
}
|
|
1492
|
-
},
|
|
1626
|
+
}, _callee15, this);
|
|
1493
1627
|
}));
|
|
1494
|
-
function addProductToOrder(
|
|
1628
|
+
function addProductToOrder(_x16, _x17) {
|
|
1495
1629
|
return _addProductToOrder.apply(this, arguments);
|
|
1496
1630
|
}
|
|
1497
1631
|
return addProductToOrder;
|
|
@@ -1516,15 +1650,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1516
1650
|
});
|
|
1517
1651
|
}
|
|
1518
1652
|
}, {
|
|
1519
|
-
key: "
|
|
1653
|
+
key: "updateOrderProduct",
|
|
1520
1654
|
value: function () {
|
|
1521
|
-
var
|
|
1655
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1522
1656
|
var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _tempOrder$products$p;
|
|
1523
|
-
var product_id, product_variant_id, updates, unique_identification_number, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta;
|
|
1524
|
-
return _regeneratorRuntime().wrap(function
|
|
1525
|
-
while (1) switch (
|
|
1657
|
+
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;
|
|
1658
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1659
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1526
1660
|
case 0:
|
|
1527
|
-
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;
|
|
1661
|
+
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;
|
|
1528
1662
|
tempOrder = this.ensureTempOrder();
|
|
1529
1663
|
identityLookup = {
|
|
1530
1664
|
product_id: product_id,
|
|
@@ -1532,16 +1666,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1532
1666
|
};
|
|
1533
1667
|
if (unique_identification_number !== undefined) {
|
|
1534
1668
|
identityLookup.unique_identification_number = unique_identification_number;
|
|
1669
|
+
if (identity_key === undefined) {
|
|
1670
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
if (identity_key !== undefined) {
|
|
1674
|
+
identityLookup.identity_key = identity_key;
|
|
1535
1675
|
}
|
|
1536
1676
|
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1537
1677
|
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1538
|
-
productIndex =
|
|
1678
|
+
productIndex = -1;
|
|
1679
|
+
if (unique_identification_number !== undefined) {
|
|
1680
|
+
targetUid = String(unique_identification_number);
|
|
1681
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1682
|
+
var _item$metadata;
|
|
1683
|
+
return String(((_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1684
|
+
});
|
|
1685
|
+
}
|
|
1686
|
+
if (productIndex === -1) {
|
|
1687
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1688
|
+
}
|
|
1539
1689
|
if (!(productIndex === -1)) {
|
|
1540
|
-
|
|
1690
|
+
_context16.next = 12;
|
|
1541
1691
|
break;
|
|
1542
1692
|
}
|
|
1543
1693
|
throw new Error('[Order] 目标商品不存在,无法更新');
|
|
1544
|
-
case
|
|
1694
|
+
case 12:
|
|
1545
1695
|
targetProduct = tempOrder.products[productIndex];
|
|
1546
1696
|
nextProduct = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), updates), {}, {
|
|
1547
1697
|
product_id: product_id,
|
|
@@ -1569,57 +1719,217 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1569
1719
|
}
|
|
1570
1720
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
1571
1721
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
1572
|
-
|
|
1722
|
+
normalizedProduct = normalizeOrderProduct(nextProduct);
|
|
1723
|
+
if (booking) {
|
|
1724
|
+
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());
|
|
1725
|
+
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1726
|
+
unique_identification_number: productUid
|
|
1727
|
+
});
|
|
1728
|
+
linked = this.createLinkedProductAndBooking({
|
|
1729
|
+
product: _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1730
|
+
unique_identification_number: productUid
|
|
1731
|
+
}),
|
|
1732
|
+
booking: booking
|
|
1733
|
+
});
|
|
1734
|
+
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
1735
|
+
normalizedProduct = _objectSpread(_objectSpread({}, normalizedProduct), {}, {
|
|
1736
|
+
booking_uid: linked.bookingUid,
|
|
1737
|
+
metadata: _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
1738
|
+
booking_uid: linked.bookingUid,
|
|
1739
|
+
unique_identification_number: productUid
|
|
1740
|
+
})
|
|
1741
|
+
});
|
|
1742
|
+
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
1743
|
+
}
|
|
1744
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1573
1745
|
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);
|
|
1574
1746
|
this.applyDiscount();
|
|
1575
|
-
|
|
1747
|
+
_context16.next = 25;
|
|
1576
1748
|
return this.recalculateSummary({
|
|
1577
1749
|
createIfMissing: true
|
|
1578
1750
|
});
|
|
1579
|
-
case
|
|
1751
|
+
case 25:
|
|
1580
1752
|
this.persistTempOrder();
|
|
1581
|
-
return
|
|
1582
|
-
case
|
|
1753
|
+
return _context16.abrupt("return", tempOrder.products);
|
|
1754
|
+
case 27:
|
|
1583
1755
|
case "end":
|
|
1584
|
-
return
|
|
1756
|
+
return _context16.stop();
|
|
1585
1757
|
}
|
|
1586
|
-
},
|
|
1758
|
+
}, _callee16, this);
|
|
1587
1759
|
}));
|
|
1588
|
-
function
|
|
1589
|
-
return
|
|
1760
|
+
function updateOrderProduct(_x18) {
|
|
1761
|
+
return _updateOrderProduct.apply(this, arguments);
|
|
1590
1762
|
}
|
|
1591
|
-
return
|
|
1763
|
+
return updateOrderProduct;
|
|
1592
1764
|
}()
|
|
1765
|
+
}, {
|
|
1766
|
+
key: "updateOrderProductQuantity",
|
|
1767
|
+
value: function () {
|
|
1768
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1769
|
+
var _targetProduct$metada4;
|
|
1770
|
+
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
1771
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1772
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1773
|
+
case 0:
|
|
1774
|
+
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;
|
|
1775
|
+
tempOrder = this.ensureTempOrder();
|
|
1776
|
+
identityLookup = {
|
|
1777
|
+
product_id: product_id,
|
|
1778
|
+
product_variant_id: product_variant_id
|
|
1779
|
+
};
|
|
1780
|
+
if (unique_identification_number !== undefined) {
|
|
1781
|
+
identityLookup.unique_identification_number = unique_identification_number;
|
|
1782
|
+
if (identity_key === undefined) {
|
|
1783
|
+
identityLookup.identity_key = unique_identification_number;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
if (identity_key !== undefined) identityLookup.identity_key = identity_key;
|
|
1787
|
+
if (product_option_item !== undefined) identityLookup.product_option_item = product_option_item;
|
|
1788
|
+
if (product_bundle !== undefined) identityLookup.product_bundle = product_bundle;
|
|
1789
|
+
productIndex = -1;
|
|
1790
|
+
if (unique_identification_number !== undefined) {
|
|
1791
|
+
targetUid = String(unique_identification_number);
|
|
1792
|
+
productIndex = tempOrder.products.findIndex(function (item) {
|
|
1793
|
+
var _item$metadata2;
|
|
1794
|
+
return String(((_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
if (productIndex === -1) {
|
|
1798
|
+
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
1799
|
+
}
|
|
1800
|
+
if (!(productIndex === -1)) {
|
|
1801
|
+
_context17.next = 12;
|
|
1802
|
+
break;
|
|
1803
|
+
}
|
|
1804
|
+
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
1805
|
+
case 12:
|
|
1806
|
+
targetProduct = tempOrder.products[productIndex];
|
|
1807
|
+
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
1808
|
+
num: getSafeProductNum(num),
|
|
1809
|
+
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
1810
|
+
unique_identification_number: ((_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.unique_identification_number) || unique_identification_number
|
|
1811
|
+
})
|
|
1812
|
+
}));
|
|
1813
|
+
tempOrder.products[productIndex] = normalizedProduct;
|
|
1814
|
+
this.applyDiscount();
|
|
1815
|
+
_context17.next = 18;
|
|
1816
|
+
return this.recalculateSummary({
|
|
1817
|
+
createIfMissing: true
|
|
1818
|
+
});
|
|
1819
|
+
case 18:
|
|
1820
|
+
this.persistTempOrder();
|
|
1821
|
+
return _context17.abrupt("return", tempOrder.products);
|
|
1822
|
+
case 20:
|
|
1823
|
+
case "end":
|
|
1824
|
+
return _context17.stop();
|
|
1825
|
+
}
|
|
1826
|
+
}, _callee17, this);
|
|
1827
|
+
}));
|
|
1828
|
+
function updateOrderProductQuantity(_x19) {
|
|
1829
|
+
return _updateOrderProductQuantity.apply(this, arguments);
|
|
1830
|
+
}
|
|
1831
|
+
return updateOrderProductQuantity;
|
|
1832
|
+
}()
|
|
1833
|
+
}, {
|
|
1834
|
+
key: "updateOrderBooking",
|
|
1835
|
+
value: function updateOrderBooking(params) {
|
|
1836
|
+
var unique_identification_number = params.unique_identification_number,
|
|
1837
|
+
updates = params.updates;
|
|
1838
|
+
var tempOrder = this.ensureTempOrder();
|
|
1839
|
+
var bookingUid = String(unique_identification_number || '');
|
|
1840
|
+
var bookingIndex = this.findBookingIndexByUniqueIdentificationNumber(tempOrder, bookingUid);
|
|
1841
|
+
if (!bookingUid || bookingIndex === -1) {
|
|
1842
|
+
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
1843
|
+
}
|
|
1844
|
+
var targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
1845
|
+
var nextBooking = _objectSpread(_objectSpread(_objectSpread({}, targetBooking), updates), {}, {
|
|
1846
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetBooking.metadata || {}), updates.metadata || {}), {}, {
|
|
1847
|
+
unique_identification_number: bookingUid
|
|
1848
|
+
})
|
|
1849
|
+
});
|
|
1850
|
+
nextBooking.is_all = normalizeBookingIsAll(nextBooking);
|
|
1851
|
+
nextBooking.sub_type = normalizeBookingSubType(nextBooking);
|
|
1852
|
+
tempOrder.bookings[bookingIndex] = nextBooking;
|
|
1853
|
+
this.persistTempOrder();
|
|
1854
|
+
return tempOrder.bookings;
|
|
1855
|
+
}
|
|
1593
1856
|
}, {
|
|
1594
1857
|
key: "removeProductFromOrder",
|
|
1595
1858
|
value: function () {
|
|
1596
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1597
|
-
var tempOrder;
|
|
1598
|
-
return _regeneratorRuntime().wrap(function
|
|
1599
|
-
while (1) switch (
|
|
1859
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(identity) {
|
|
1860
|
+
var tempOrder, removedProducts, _i, _removedProducts, product;
|
|
1861
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1862
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1600
1863
|
case 0:
|
|
1601
1864
|
tempOrder = this.ensureTempOrder();
|
|
1865
|
+
removedProducts = [];
|
|
1602
1866
|
tempOrder.products = tempOrder.products.filter(function (item) {
|
|
1603
|
-
|
|
1867
|
+
var shouldRemove = isIdentityMatch(item, identity);
|
|
1868
|
+
if (shouldRemove) removedProducts.push(item);
|
|
1869
|
+
return !shouldRemove;
|
|
1604
1870
|
});
|
|
1871
|
+
for (_i = 0, _removedProducts = removedProducts; _i < _removedProducts.length; _i++) {
|
|
1872
|
+
product = _removedProducts[_i];
|
|
1873
|
+
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
1874
|
+
}
|
|
1605
1875
|
this.applyDiscount();
|
|
1606
|
-
|
|
1876
|
+
_context18.next = 7;
|
|
1607
1877
|
return this.recalculateSummary({
|
|
1608
1878
|
createIfMissing: true
|
|
1609
1879
|
});
|
|
1610
|
-
case 5:
|
|
1611
|
-
this.persistTempOrder();
|
|
1612
|
-
return _context15.abrupt("return", tempOrder.products);
|
|
1613
1880
|
case 7:
|
|
1881
|
+
this.persistTempOrder();
|
|
1882
|
+
return _context18.abrupt("return", tempOrder.products);
|
|
1883
|
+
case 9:
|
|
1614
1884
|
case "end":
|
|
1615
|
-
return
|
|
1885
|
+
return _context18.stop();
|
|
1616
1886
|
}
|
|
1617
|
-
},
|
|
1887
|
+
}, _callee18, this);
|
|
1618
1888
|
}));
|
|
1619
|
-
function removeProductFromOrder(
|
|
1889
|
+
function removeProductFromOrder(_x20) {
|
|
1620
1890
|
return _removeProductFromOrder.apply(this, arguments);
|
|
1621
1891
|
}
|
|
1622
1892
|
return removeProductFromOrder;
|
|
1893
|
+
}()
|
|
1894
|
+
/**
|
|
1895
|
+
* 仅清空购物车行(products / bookings / discount_list),不重置整单。
|
|
1896
|
+
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
1897
|
+
*/
|
|
1898
|
+
}, {
|
|
1899
|
+
key: "clearOrderCartLines",
|
|
1900
|
+
value: (function () {
|
|
1901
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1902
|
+
var tempOrder;
|
|
1903
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1904
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1905
|
+
case 0:
|
|
1906
|
+
tempOrder = this.ensureTempOrder();
|
|
1907
|
+
tempOrder.products = [];
|
|
1908
|
+
tempOrder.bookings = [];
|
|
1909
|
+
tempOrder.discount_list = [];
|
|
1910
|
+
if (tempOrder._extend && _typeof(tempOrder._extend) === 'object') {
|
|
1911
|
+
tempOrder._extend = _objectSpread(_objectSpread({}, tempOrder._extend), {}, {
|
|
1912
|
+
productsByUid: {}
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
this.applyDiscount();
|
|
1916
|
+
_context19.next = 8;
|
|
1917
|
+
return this.recalculateSummary({
|
|
1918
|
+
createIfMissing: true
|
|
1919
|
+
});
|
|
1920
|
+
case 8:
|
|
1921
|
+
this.persistTempOrder();
|
|
1922
|
+
return _context19.abrupt("return", tempOrder);
|
|
1923
|
+
case 10:
|
|
1924
|
+
case "end":
|
|
1925
|
+
return _context19.stop();
|
|
1926
|
+
}
|
|
1927
|
+
}, _callee19, this);
|
|
1928
|
+
}));
|
|
1929
|
+
function clearOrderCartLines() {
|
|
1930
|
+
return _clearOrderCartLines.apply(this, arguments);
|
|
1931
|
+
}
|
|
1932
|
+
return clearOrderCartLines;
|
|
1623
1933
|
}() // ─── TempOrder: 提交 ───
|
|
1624
1934
|
/**
|
|
1625
1935
|
* 提交当前 Sales tempOrder。
|
|
@@ -1627,14 +1937,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1627
1937
|
* smallTicketDataFlag 用于 B 端 checkout 小票数据返回。PaymentModal 在支付提交时
|
|
1628
1938
|
* 应传 1,确保 /order/sales/checkout 返回打印所需数据。
|
|
1629
1939
|
*/
|
|
1940
|
+
)
|
|
1630
1941
|
}, {
|
|
1631
1942
|
key: "submitTempOrder",
|
|
1632
1943
|
value: function () {
|
|
1633
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1944
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1634
1945
|
var _params$cacheId, _this$otherParams;
|
|
1635
1946
|
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
1636
|
-
return _regeneratorRuntime().wrap(function
|
|
1637
|
-
while (1) switch (
|
|
1947
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1948
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1638
1949
|
case 0:
|
|
1639
1950
|
tempOrder = this.ensureTempOrder();
|
|
1640
1951
|
this.persistTempOrder();
|
|
@@ -1661,10 +1972,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1661
1972
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
1662
1973
|
enhance: enhancePayload
|
|
1663
1974
|
});
|
|
1664
|
-
|
|
1975
|
+
_context20.next = 10;
|
|
1665
1976
|
return this.saveDraft();
|
|
1666
1977
|
case 10:
|
|
1667
|
-
|
|
1978
|
+
_context20.prev = 10;
|
|
1668
1979
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
1669
1980
|
orderId: payload.order_id,
|
|
1670
1981
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -1672,62 +1983,62 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1672
1983
|
paymentsCount: ((_payload$payments = payload.payments) === null || _payload$payments === void 0 ? void 0 : _payload$payments.length) || 0,
|
|
1673
1984
|
smallTicketDataFlag: payload.small_ticket_data_flag
|
|
1674
1985
|
});
|
|
1675
|
-
|
|
1986
|
+
_context20.next = 14;
|
|
1676
1987
|
return this.submitSalesOrder({
|
|
1677
1988
|
query: payload
|
|
1678
1989
|
});
|
|
1679
1990
|
case 14:
|
|
1680
|
-
result =
|
|
1681
|
-
|
|
1991
|
+
result = _context20.sent;
|
|
1992
|
+
_context20.next = 27;
|
|
1682
1993
|
break;
|
|
1683
1994
|
case 17:
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
1995
|
+
_context20.prev = 17;
|
|
1996
|
+
_context20.t0 = _context20["catch"](10);
|
|
1997
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context20.t0);
|
|
1687
1998
|
if (!backendErrorResponse) {
|
|
1688
|
-
|
|
1999
|
+
_context20.next = 24;
|
|
1689
2000
|
break;
|
|
1690
2001
|
}
|
|
1691
2002
|
this.store.syncState = 'failed';
|
|
1692
2003
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
1693
|
-
return
|
|
2004
|
+
return _context20.abrupt("return", backendErrorResponse);
|
|
1694
2005
|
case 24:
|
|
1695
2006
|
this.store.syncState = 'failed';
|
|
1696
2007
|
this.logError('submitTempOrder failed', {
|
|
1697
|
-
error:
|
|
2008
|
+
error: _context20.t0 instanceof Error ? _context20.t0.message : String(_context20.t0),
|
|
1698
2009
|
orderId: payload.order_id,
|
|
1699
2010
|
externalSaleNumber: payload.external_sale_number,
|
|
1700
2011
|
paymentStatus: payload.payment_status,
|
|
1701
2012
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
1702
2013
|
});
|
|
1703
|
-
throw
|
|
2014
|
+
throw _context20.t0;
|
|
1704
2015
|
case 27:
|
|
1705
2016
|
if (!this.isSubmitResponseRejected(result)) {
|
|
1706
|
-
|
|
2017
|
+
_context20.next = 31;
|
|
1707
2018
|
break;
|
|
1708
2019
|
}
|
|
1709
2020
|
this.store.syncState = 'failed';
|
|
1710
2021
|
this.logSubmitBackendRejected(result, payload);
|
|
1711
|
-
return
|
|
2022
|
+
return _context20.abrupt("return", result);
|
|
1712
2023
|
case 31:
|
|
1713
2024
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
1714
2025
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
1715
|
-
|
|
2026
|
+
_context20.next = 37;
|
|
1716
2027
|
break;
|
|
1717
2028
|
}
|
|
1718
2029
|
tempOrder.order_id = submittedOrderId;
|
|
1719
2030
|
resultRecord = result;
|
|
1720
|
-
|
|
2031
|
+
_context20.next = 37;
|
|
1721
2032
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
1722
2033
|
case 37:
|
|
1723
|
-
return
|
|
2034
|
+
return _context20.abrupt("return", result);
|
|
1724
2035
|
case 38:
|
|
1725
2036
|
case "end":
|
|
1726
|
-
return
|
|
2037
|
+
return _context20.stop();
|
|
1727
2038
|
}
|
|
1728
|
-
},
|
|
2039
|
+
}, _callee20, this, [[10, 17]]);
|
|
1729
2040
|
}));
|
|
1730
|
-
function submitTempOrder(
|
|
2041
|
+
function submitTempOrder(_x21) {
|
|
1731
2042
|
return _submitTempOrder.apply(this, arguments);
|
|
1732
2043
|
}
|
|
1733
2044
|
return submitTempOrder;
|
|
@@ -1735,25 +2046,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1735
2046
|
}, {
|
|
1736
2047
|
key: "markLocalOrderSynced",
|
|
1737
2048
|
value: function () {
|
|
1738
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2049
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderId, remoteOrder) {
|
|
1739
2050
|
var tempOrder;
|
|
1740
|
-
return _regeneratorRuntime().wrap(function
|
|
1741
|
-
while (1) switch (
|
|
2051
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
2052
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1742
2053
|
case 0:
|
|
1743
2054
|
tempOrder = this.ensureTempOrder();
|
|
1744
2055
|
tempOrder.order_id = orderId;
|
|
1745
2056
|
this.store.lastOrderInfo = remoteOrder;
|
|
1746
2057
|
this.store.syncState = 'submitted';
|
|
1747
2058
|
this.persistTempOrder();
|
|
1748
|
-
|
|
2059
|
+
_context21.next = 7;
|
|
1749
2060
|
return this.saveDraft();
|
|
1750
2061
|
case 7:
|
|
1751
2062
|
case "end":
|
|
1752
|
-
return
|
|
2063
|
+
return _context21.stop();
|
|
1753
2064
|
}
|
|
1754
|
-
},
|
|
2065
|
+
}, _callee21, this);
|
|
1755
2066
|
}));
|
|
1756
|
-
function markLocalOrderSynced(
|
|
2067
|
+
function markLocalOrderSynced(_x22, _x23) {
|
|
1757
2068
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
1758
2069
|
}
|
|
1759
2070
|
return markLocalOrderSynced;
|
|
@@ -1777,10 +2088,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1777
2088
|
value: function extractSubmitErrorResponse(error) {
|
|
1778
2089
|
var _error$response,
|
|
1779
2090
|
_error$response2,
|
|
1780
|
-
|
|
2091
|
+
_this6 = this;
|
|
1781
2092
|
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];
|
|
1782
2093
|
return candidates.find(function (candidate) {
|
|
1783
|
-
return
|
|
2094
|
+
return _this6.isSubmitErrorResponse(candidate);
|
|
1784
2095
|
}) || null;
|
|
1785
2096
|
}
|
|
1786
2097
|
}, {
|
|
@@ -1800,49 +2111,50 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1800
2111
|
}, {
|
|
1801
2112
|
key: "syncPaymentsToOrder",
|
|
1802
2113
|
value: function () {
|
|
1803
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2114
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
1804
2115
|
var tempOrder, mappedPayments, paymentTotal, targetAmount, isFullyPaid, submitResult;
|
|
1805
|
-
return _regeneratorRuntime().wrap(function
|
|
1806
|
-
while (1) switch (
|
|
2116
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2117
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1807
2118
|
case 0:
|
|
1808
2119
|
tempOrder = this.ensureTempOrder();
|
|
1809
2120
|
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
1810
2121
|
tempOrder.payments = mappedPayments;
|
|
1811
2122
|
if (params.paymentStatus) tempOrder.payment_status = params.paymentStatus;
|
|
1812
2123
|
this.persistTempOrder();
|
|
1813
|
-
|
|
2124
|
+
_context22.next = 7;
|
|
1814
2125
|
return this.saveDraft();
|
|
1815
2126
|
case 7:
|
|
1816
2127
|
paymentTotal = this.calculatePaymentTotal(mappedPayments);
|
|
1817
2128
|
targetAmount = this.getPaymentTargetAmount();
|
|
1818
2129
|
isFullyPaid = targetAmount.lte(0) ? false : paymentTotal.gte(targetAmount);
|
|
1819
2130
|
if (!(!isFullyPaid || !params.submitWhenPaid)) {
|
|
1820
|
-
|
|
2131
|
+
_context22.next = 12;
|
|
1821
2132
|
break;
|
|
1822
2133
|
}
|
|
1823
|
-
return
|
|
2134
|
+
return _context22.abrupt("return", {
|
|
1824
2135
|
isFullyPaid: isFullyPaid
|
|
1825
2136
|
});
|
|
1826
2137
|
case 12:
|
|
1827
|
-
|
|
2138
|
+
_context22.next = 14;
|
|
1828
2139
|
return this.submitTempOrder({
|
|
1829
2140
|
payments: mappedPayments,
|
|
1830
2141
|
paymentStatus: params.paymentStatus || 'paid',
|
|
1831
|
-
smallTicketDataFlag: params.smallTicketDataFlag
|
|
2142
|
+
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2143
|
+
channel: params.channel
|
|
1832
2144
|
});
|
|
1833
2145
|
case 14:
|
|
1834
|
-
submitResult =
|
|
1835
|
-
return
|
|
2146
|
+
submitResult = _context22.sent;
|
|
2147
|
+
return _context22.abrupt("return", {
|
|
1836
2148
|
isFullyPaid: isFullyPaid,
|
|
1837
2149
|
submitResult: submitResult
|
|
1838
2150
|
});
|
|
1839
2151
|
case 16:
|
|
1840
2152
|
case "end":
|
|
1841
|
-
return
|
|
2153
|
+
return _context22.stop();
|
|
1842
2154
|
}
|
|
1843
|
-
},
|
|
2155
|
+
}, _callee22, this);
|
|
1844
2156
|
}));
|
|
1845
|
-
function syncPaymentsToOrder(
|
|
2157
|
+
function syncPaymentsToOrder(_x24) {
|
|
1846
2158
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
1847
2159
|
}
|
|
1848
2160
|
return syncPaymentsToOrder;
|
|
@@ -1931,11 +2243,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1931
2243
|
}, {
|
|
1932
2244
|
key: "submitOrder",
|
|
1933
2245
|
value: function () {
|
|
1934
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2246
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(order) {
|
|
1935
2247
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
1936
2248
|
var url, query, fetchUrl, params;
|
|
1937
|
-
return _regeneratorRuntime().wrap(function
|
|
1938
|
-
while (1) switch (
|
|
2249
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2250
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1939
2251
|
case 0:
|
|
1940
2252
|
this.logInfo('submitOrder called', {
|
|
1941
2253
|
url: order.url,
|
|
@@ -1955,14 +2267,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1955
2267
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
1956
2268
|
scheduleDate: params.schedule_date
|
|
1957
2269
|
});
|
|
1958
|
-
return
|
|
2270
|
+
return _context23.abrupt("return", this.request.post(fetchUrl, params));
|
|
1959
2271
|
case 6:
|
|
1960
2272
|
case "end":
|
|
1961
|
-
return
|
|
2273
|
+
return _context23.stop();
|
|
1962
2274
|
}
|
|
1963
|
-
},
|
|
2275
|
+
}, _callee23, this);
|
|
1964
2276
|
}));
|
|
1965
|
-
function submitOrder(
|
|
2277
|
+
function submitOrder(_x25) {
|
|
1966
2278
|
return _submitOrder.apply(this, arguments);
|
|
1967
2279
|
}
|
|
1968
2280
|
return submitOrder;
|
|
@@ -1970,13 +2282,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1970
2282
|
}, {
|
|
1971
2283
|
key: "cancelOrder",
|
|
1972
2284
|
value: function () {
|
|
1973
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2285
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
1974
2286
|
var payload;
|
|
1975
|
-
return _regeneratorRuntime().wrap(function
|
|
1976
|
-
while (1) switch (
|
|
2287
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2288
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1977
2289
|
case 0:
|
|
1978
2290
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
1979
|
-
|
|
2291
|
+
_context24.next = 2;
|
|
1980
2292
|
break;
|
|
1981
2293
|
}
|
|
1982
2294
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -1992,16 +2304,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2304
|
method: 'PUT',
|
|
1993
2305
|
orderIdsCount: params.order_ids.length
|
|
1994
2306
|
});
|
|
1995
|
-
return
|
|
2307
|
+
return _context24.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
1996
2308
|
isShopApi: true
|
|
1997
2309
|
}));
|
|
1998
2310
|
case 5:
|
|
1999
2311
|
case "end":
|
|
2000
|
-
return
|
|
2312
|
+
return _context24.stop();
|
|
2001
2313
|
}
|
|
2002
|
-
},
|
|
2314
|
+
}, _callee24, this);
|
|
2003
2315
|
}));
|
|
2004
|
-
function cancelOrder(
|
|
2316
|
+
function cancelOrder(_x26) {
|
|
2005
2317
|
return _cancelOrder.apply(this, arguments);
|
|
2006
2318
|
}
|
|
2007
2319
|
return cancelOrder;
|
|
@@ -2009,19 +2321,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2009
2321
|
}, {
|
|
2010
2322
|
key: "changeBookingStatus",
|
|
2011
2323
|
value: function () {
|
|
2012
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2324
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
2013
2325
|
var url, payload;
|
|
2014
|
-
return _regeneratorRuntime().wrap(function
|
|
2015
|
-
while (1) switch (
|
|
2326
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2327
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2016
2328
|
case 0:
|
|
2017
2329
|
if (params.booking_id) {
|
|
2018
|
-
|
|
2330
|
+
_context25.next = 2;
|
|
2019
2331
|
break;
|
|
2020
2332
|
}
|
|
2021
2333
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
2022
2334
|
case 2:
|
|
2023
2335
|
if (params.appointment_status) {
|
|
2024
|
-
|
|
2336
|
+
_context25.next = 4;
|
|
2025
2337
|
break;
|
|
2026
2338
|
}
|
|
2027
2339
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -2036,16 +2348,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2348
|
bookingId: params.booking_id,
|
|
2037
2349
|
appointmentStatus: params.appointment_status
|
|
2038
2350
|
});
|
|
2039
|
-
return
|
|
2351
|
+
return _context25.abrupt("return", this.request.put(url, payload, {
|
|
2040
2352
|
isShopApi: true
|
|
2041
2353
|
}));
|
|
2042
2354
|
case 8:
|
|
2043
2355
|
case "end":
|
|
2044
|
-
return
|
|
2356
|
+
return _context25.stop();
|
|
2045
2357
|
}
|
|
2046
|
-
},
|
|
2358
|
+
}, _callee25, this);
|
|
2047
2359
|
}));
|
|
2048
|
-
function changeBookingStatus(
|
|
2360
|
+
function changeBookingStatus(_x27) {
|
|
2049
2361
|
return _changeBookingStatus.apply(this, arguments);
|
|
2050
2362
|
}
|
|
2051
2363
|
return changeBookingStatus;
|
|
@@ -2063,11 +2375,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2063
2375
|
}, {
|
|
2064
2376
|
key: "createOrderByCheckout",
|
|
2065
2377
|
value: (function () {
|
|
2066
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2378
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
|
|
2067
2379
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
2068
2380
|
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;
|
|
2069
|
-
return _regeneratorRuntime().wrap(function
|
|
2070
|
-
while (1) switch (
|
|
2381
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2382
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2071
2383
|
case 0:
|
|
2072
2384
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
2073
2385
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -2101,7 +2413,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2101
2413
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
2102
2414
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
2103
2415
|
});
|
|
2104
|
-
|
|
2416
|
+
_context26.prev = 4;
|
|
2105
2417
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
2106
2418
|
orderData = _objectSpread({
|
|
2107
2419
|
sales_channel: 'my_pisel',
|
|
@@ -2165,10 +2477,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2165
2477
|
});
|
|
2166
2478
|
|
|
2167
2479
|
// 调用后端接口
|
|
2168
|
-
|
|
2480
|
+
_context26.next = 12;
|
|
2169
2481
|
return this.request.post('/order/checkout', orderData);
|
|
2170
2482
|
case 12:
|
|
2171
|
-
response =
|
|
2483
|
+
response = _context26.sent;
|
|
2172
2484
|
this.logInfo('Order API called successfully', {
|
|
2173
2485
|
response: response
|
|
2174
2486
|
});
|
|
@@ -2176,22 +2488,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2176
2488
|
success: !!response,
|
|
2177
2489
|
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)
|
|
2178
2490
|
});
|
|
2179
|
-
return
|
|
2491
|
+
return _context26.abrupt("return", response);
|
|
2180
2492
|
case 18:
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
2493
|
+
_context26.prev = 18;
|
|
2494
|
+
_context26.t0 = _context26["catch"](4);
|
|
2495
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context26.t0);
|
|
2184
2496
|
this.logInfo('Order API called failed', {
|
|
2185
|
-
error:
|
|
2497
|
+
error: _context26.t0 instanceof Error ? _context26.t0.message : String(_context26.t0)
|
|
2186
2498
|
});
|
|
2187
|
-
throw
|
|
2499
|
+
throw _context26.t0;
|
|
2188
2500
|
case 23:
|
|
2189
2501
|
case "end":
|
|
2190
|
-
return
|
|
2502
|
+
return _context26.stop();
|
|
2191
2503
|
}
|
|
2192
|
-
},
|
|
2504
|
+
}, _callee26, this, [[4, 18]]);
|
|
2193
2505
|
}));
|
|
2194
|
-
function createOrderByCheckout(
|
|
2506
|
+
function createOrderByCheckout(_x28) {
|
|
2195
2507
|
return _createOrderByCheckout.apply(this, arguments);
|
|
2196
2508
|
}
|
|
2197
2509
|
return createOrderByCheckout;
|
|
@@ -2199,23 +2511,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2199
2511
|
}, {
|
|
2200
2512
|
key: "submitSalesOrder",
|
|
2201
2513
|
value: function () {
|
|
2202
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2514
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2203
2515
|
var url, query, fetchUrl;
|
|
2204
|
-
return _regeneratorRuntime().wrap(function
|
|
2205
|
-
while (1) switch (
|
|
2516
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2517
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2206
2518
|
case 0:
|
|
2207
2519
|
url = params.url, query = params.query;
|
|
2208
2520
|
fetchUrl = url || '/order/sales/checkout';
|
|
2209
|
-
return
|
|
2521
|
+
return _context27.abrupt("return", this.request.post(fetchUrl, query, {
|
|
2210
2522
|
customToast: function customToast() {}
|
|
2211
2523
|
}));
|
|
2212
2524
|
case 3:
|
|
2213
2525
|
case "end":
|
|
2214
|
-
return
|
|
2526
|
+
return _context27.stop();
|
|
2215
2527
|
}
|
|
2216
|
-
},
|
|
2528
|
+
}, _callee27, this);
|
|
2217
2529
|
}));
|
|
2218
|
-
function submitSalesOrder(
|
|
2530
|
+
function submitSalesOrder(_x29) {
|
|
2219
2531
|
return _submitSalesOrder.apply(this, arguments);
|
|
2220
2532
|
}
|
|
2221
2533
|
return submitSalesOrder;
|
|
@@ -2229,37 +2541,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2229
2541
|
}, {
|
|
2230
2542
|
key: "sendCustomerPayLink",
|
|
2231
2543
|
value: (function () {
|
|
2232
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2544
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2233
2545
|
var _params$emails;
|
|
2234
2546
|
var orderIds;
|
|
2235
|
-
return _regeneratorRuntime().wrap(function
|
|
2236
|
-
while (1) switch (
|
|
2547
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2548
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2237
2549
|
case 0:
|
|
2238
2550
|
orderIds = params.order_ids || params.orderIds || [];
|
|
2239
2551
|
if (orderIds.length) {
|
|
2240
|
-
|
|
2552
|
+
_context28.next = 3;
|
|
2241
2553
|
break;
|
|
2242
2554
|
}
|
|
2243
2555
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
2244
2556
|
case 3:
|
|
2245
2557
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
2246
|
-
|
|
2558
|
+
_context28.next = 5;
|
|
2247
2559
|
break;
|
|
2248
2560
|
}
|
|
2249
2561
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
2250
2562
|
case 5:
|
|
2251
|
-
return
|
|
2563
|
+
return _context28.abrupt("return", this.request.post('/order/batch-email', {
|
|
2252
2564
|
order_ids: orderIds,
|
|
2253
2565
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
2254
2566
|
emails: params.emails
|
|
2255
2567
|
}));
|
|
2256
2568
|
case 6:
|
|
2257
2569
|
case "end":
|
|
2258
|
-
return
|
|
2570
|
+
return _context28.stop();
|
|
2259
2571
|
}
|
|
2260
|
-
},
|
|
2572
|
+
}, _callee28, this);
|
|
2261
2573
|
}));
|
|
2262
|
-
function sendCustomerPayLink(
|
|
2574
|
+
function sendCustomerPayLink(_x30) {
|
|
2263
2575
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
2264
2576
|
}
|
|
2265
2577
|
return sendCustomerPayLink;
|
|
@@ -2268,28 +2580,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2268
2580
|
}, {
|
|
2269
2581
|
key: "getOrderInfoByRemote",
|
|
2270
2582
|
value: function () {
|
|
2271
|
-
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2583
|
+
var _getOrderInfoByRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(order_id) {
|
|
2272
2584
|
var res;
|
|
2273
|
-
return _regeneratorRuntime().wrap(function
|
|
2274
|
-
while (1) switch (
|
|
2585
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2586
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2275
2587
|
case 0:
|
|
2276
|
-
|
|
2588
|
+
_context29.next = 2;
|
|
2277
2589
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2278
2590
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
2279
2591
|
});
|
|
2280
2592
|
case 2:
|
|
2281
|
-
res =
|
|
2593
|
+
res = _context29.sent;
|
|
2282
2594
|
if (res.code === 200) {
|
|
2283
2595
|
this.store.lastOrderInfo = res.data;
|
|
2284
2596
|
}
|
|
2285
|
-
return
|
|
2597
|
+
return _context29.abrupt("return", res);
|
|
2286
2598
|
case 5:
|
|
2287
2599
|
case "end":
|
|
2288
|
-
return
|
|
2600
|
+
return _context29.stop();
|
|
2289
2601
|
}
|
|
2290
|
-
},
|
|
2602
|
+
}, _callee29, this);
|
|
2291
2603
|
}));
|
|
2292
|
-
function getOrderInfoByRemote(
|
|
2604
|
+
function getOrderInfoByRemote(_x31) {
|
|
2293
2605
|
return _getOrderInfoByRemote.apply(this, arguments);
|
|
2294
2606
|
}
|
|
2295
2607
|
return getOrderInfoByRemote;
|
|
@@ -2303,79 +2615,84 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2303
2615
|
}, {
|
|
2304
2616
|
key: "hydrateTempOrderFromRecord",
|
|
2305
2617
|
value: (function () {
|
|
2306
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2307
|
-
var
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
while (1) switch (_context26.prev = _context26.next) {
|
|
2618
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(record, options) {
|
|
2619
|
+
var raw, nextTempOrder;
|
|
2620
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2621
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2311
2622
|
case 0:
|
|
2312
2623
|
raw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
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'];
|
|
2316
|
-
TEMP_ORDER_KEYS.forEach(function (key) {
|
|
2317
|
-
if (raw[key] !== undefined) {
|
|
2318
|
-
nextTempOrder[key] = raw[key];
|
|
2319
|
-
}
|
|
2624
|
+
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
2625
|
+
ensureIdentity: true
|
|
2320
2626
|
});
|
|
2321
|
-
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
2322
|
-
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
2323
|
-
nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
|
|
2324
|
-
return _this5.normalizeHydratedOrderProduct(p);
|
|
2325
|
-
}) : [];
|
|
2326
|
-
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
2327
|
-
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
2328
|
-
is_all: normalizeBookingIsAll(b || {}),
|
|
2329
|
-
sub_type: normalizeBookingSubType(b || {})
|
|
2330
|
-
});
|
|
2331
|
-
}) : [];
|
|
2332
|
-
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
2333
|
-
return _objectSpread({}, p || {});
|
|
2334
|
-
}) : [];
|
|
2335
|
-
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
2336
|
-
return _objectSpread({}, s || {});
|
|
2337
|
-
}) : [];
|
|
2338
|
-
nextTempOrder.discount_list = Array.isArray(raw.discount_list) ? raw.discount_list.map(function (d) {
|
|
2339
|
-
return _objectSpread({}, d || {});
|
|
2340
|
-
}) : [];
|
|
2341
|
-
nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
|
|
2342
|
-
return _objectSpread({}, f || {});
|
|
2343
|
-
}) : [];
|
|
2344
|
-
nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
|
|
2345
|
-
return _objectSpread({}, c || {});
|
|
2346
|
-
}) : [];
|
|
2347
|
-
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
2348
|
-
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
2349
|
-
productsByUid: raw._extend.productsByUid || {}
|
|
2350
|
-
}) : {
|
|
2351
|
-
productsByUid: {}
|
|
2352
|
-
};
|
|
2353
|
-
this.ensureExternalSaleNumber(nextTempOrder);
|
|
2354
2627
|
this.store.tempOrder = nextTempOrder;
|
|
2355
2628
|
this.store.summary = raw.summary && _typeof(raw.summary) === 'object' ? _objectSpread(_objectSpread({}, createEmptySummary()), raw.summary) : createEmptySummary();
|
|
2356
2629
|
this.store.lastOrderInfo = raw.lastOrderInfo || raw;
|
|
2357
2630
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
2358
|
-
|
|
2631
|
+
_context30.next = 8;
|
|
2359
2632
|
break;
|
|
2360
2633
|
}
|
|
2361
|
-
|
|
2634
|
+
_context30.next = 8;
|
|
2362
2635
|
return this.recalculateSummary({
|
|
2363
2636
|
createIfMissing: false
|
|
2364
2637
|
});
|
|
2365
|
-
case
|
|
2638
|
+
case 8:
|
|
2366
2639
|
this.persistTempOrder();
|
|
2367
|
-
return
|
|
2368
|
-
case
|
|
2640
|
+
return _context30.abrupt("return", nextTempOrder);
|
|
2641
|
+
case 10:
|
|
2369
2642
|
case "end":
|
|
2370
|
-
return
|
|
2643
|
+
return _context30.stop();
|
|
2371
2644
|
}
|
|
2372
|
-
},
|
|
2645
|
+
}, _callee30, this);
|
|
2373
2646
|
}));
|
|
2374
|
-
function hydrateTempOrderFromRecord(
|
|
2647
|
+
function hydrateTempOrderFromRecord(_x32, _x33) {
|
|
2375
2648
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
2376
2649
|
}
|
|
2377
2650
|
return hydrateTempOrderFromRecord;
|
|
2378
2651
|
}())
|
|
2652
|
+
}, {
|
|
2653
|
+
key: "normalizeTempOrderForRuntime",
|
|
2654
|
+
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
2655
|
+
var _this7 = this;
|
|
2656
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
2657
|
+
delete nextTempOrder.summary;
|
|
2658
|
+
delete nextTempOrder.lastOrderInfo;
|
|
2659
|
+
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
2660
|
+
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
2661
|
+
nextTempOrder.products = Array.isArray(raw.products) ? raw.products.map(function (p) {
|
|
2662
|
+
return _this7.normalizeHydratedOrderProduct(p);
|
|
2663
|
+
}) : [];
|
|
2664
|
+
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
2665
|
+
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
2666
|
+
is_all: normalizeBookingIsAll(b || {}),
|
|
2667
|
+
sub_type: normalizeBookingSubType(b || {})
|
|
2668
|
+
});
|
|
2669
|
+
}) : [];
|
|
2670
|
+
nextTempOrder.payments = Array.isArray(raw.payments) ? raw.payments.map(function (p) {
|
|
2671
|
+
return _objectSpread({}, p || {});
|
|
2672
|
+
}) : [];
|
|
2673
|
+
nextTempOrder.surcharges = Array.isArray(raw.surcharges) ? raw.surcharges.map(function (s) {
|
|
2674
|
+
return _objectSpread({}, s || {});
|
|
2675
|
+
}) : [];
|
|
2676
|
+
nextTempOrder.discount_list = Array.isArray(raw.discount_list) ? raw.discount_list.map(function (d) {
|
|
2677
|
+
return _objectSpread({}, d || {});
|
|
2678
|
+
}) : [];
|
|
2679
|
+
nextTempOrder.relation_forms = Array.isArray(raw.relation_forms) ? raw.relation_forms.map(function (f) {
|
|
2680
|
+
return _objectSpread({}, f || {});
|
|
2681
|
+
}) : [];
|
|
2682
|
+
nextTempOrder.contacts = Array.isArray(raw.contacts) ? raw.contacts.map(function (c) {
|
|
2683
|
+
return _objectSpread({}, c || {});
|
|
2684
|
+
}) : [];
|
|
2685
|
+
nextTempOrder.contacts_info = raw.contacts_info && _typeof(raw.contacts_info) === 'object' && !Array.isArray(raw.contacts_info) ? _objectSpread({}, raw.contacts_info) : null;
|
|
2686
|
+
nextTempOrder._extend = raw._extend && _typeof(raw._extend) === 'object' ? _objectSpread(_objectSpread({}, raw._extend), {}, {
|
|
2687
|
+
productsByUid: raw._extend.productsByUid || {}
|
|
2688
|
+
}) : {
|
|
2689
|
+
productsByUid: {}
|
|
2690
|
+
};
|
|
2691
|
+
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
2692
|
+
this.ensureExternalSaleNumber(nextTempOrder);
|
|
2693
|
+
}
|
|
2694
|
+
return nextTempOrder;
|
|
2695
|
+
}
|
|
2379
2696
|
}, {
|
|
2380
2697
|
key: "normalizeHydratedOrderProduct",
|
|
2381
2698
|
value: function normalizeHydratedOrderProduct(product) {
|
|
@@ -2406,25 +2723,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2406
2723
|
}, {
|
|
2407
2724
|
key: "getOrderInfo",
|
|
2408
2725
|
value: function () {
|
|
2409
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2726
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(order_id) {
|
|
2410
2727
|
var res;
|
|
2411
|
-
return _regeneratorRuntime().wrap(function
|
|
2412
|
-
while (1) switch (
|
|
2728
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2729
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2413
2730
|
case 0:
|
|
2414
|
-
|
|
2731
|
+
_context31.next = 2;
|
|
2415
2732
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
2416
2733
|
with: ['products', 'bookings']
|
|
2417
2734
|
});
|
|
2418
2735
|
case 2:
|
|
2419
|
-
res =
|
|
2420
|
-
return
|
|
2736
|
+
res = _context31.sent;
|
|
2737
|
+
return _context31.abrupt("return", res);
|
|
2421
2738
|
case 4:
|
|
2422
2739
|
case "end":
|
|
2423
|
-
return
|
|
2740
|
+
return _context31.stop();
|
|
2424
2741
|
}
|
|
2425
|
-
},
|
|
2742
|
+
}, _callee31, this);
|
|
2426
2743
|
}));
|
|
2427
|
-
function getOrderInfo(
|
|
2744
|
+
function getOrderInfo(_x34) {
|
|
2428
2745
|
return _getOrderInfo.apply(this, arguments);
|
|
2429
2746
|
}
|
|
2430
2747
|
return getOrderInfo;
|