@pisell/pisellos 2.2.171 → 2.2.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +193 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +215 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +129 -83
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +2 -4
- package/dist/modules/Discount/index.js +8 -93
- package/dist/modules/Discount/types.d.ts +1 -7
- package/dist/modules/Order/index.d.ts +33 -17
- package/dist/modules/Order/index.js +757 -395
- package/dist/modules/Order/types.d.ts +58 -17
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +39 -1
- package/dist/modules/Order/utils.js +219 -31
- package/dist/modules/Quotation/index.js +16 -5
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/Schedule/index.js +6 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/server/index.js +10 -6
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/server/modules/products/index.js +113 -94
- package/dist/server/modules/schedule/index.js +13 -6
- package/dist/solution/BaseSales/index.d.ts +53 -7
- package/dist/solution/BaseSales/index.js +1160 -339
- package/dist/solution/BaseSales/types.d.ts +67 -1
- package/dist/solution/BaseSales/types.js +3 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +237 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +65 -15
- package/dist/solution/BaseSales/utils.js +46 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +134 -2
- package/dist/solution/BookingTicket/index.js +776 -175
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +46 -8
- package/dist/solution/ShopDiscount/index.d.ts +0 -1
- package/dist/solution/ShopDiscount/index.js +18 -23
- package/dist/solution/VenueBooking/index.d.ts +5 -9
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +207 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +75 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +198 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +26 -11
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +2 -4
- package/lib/modules/Discount/index.js +8 -63
- package/lib/modules/Discount/types.d.ts +1 -7
- package/lib/modules/Order/index.d.ts +33 -17
- package/lib/modules/Order/index.js +402 -148
- package/lib/modules/Order/types.d.ts +58 -17
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +39 -1
- package/lib/modules/Order/utils.js +197 -22
- package/lib/modules/Quotation/index.js +17 -6
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/Schedule/index.js +3 -1
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/server/index.js +2 -0
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/server/modules/products/index.js +23 -12
- package/lib/server/modules/schedule/index.js +2 -1
- package/lib/solution/BaseSales/index.d.ts +53 -7
- package/lib/solution/BaseSales/index.js +527 -20
- package/lib/solution/BaseSales/types.d.ts +67 -1
- package/lib/solution/BaseSales/types.js +3 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +277 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +70 -11
- package/lib/solution/BaseSales/utils.js +46 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +134 -2
- package/lib/solution/BookingTicket/index.js +349 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +113 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +318 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +46 -6
- package/lib/solution/ShopDiscount/index.d.ts +0 -1
- package/lib/solution/ShopDiscount/index.js +2 -4
- package/lib/solution/VenueBooking/index.d.ts +5 -9
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +2 -2
|
@@ -30,12 +30,16 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
30
30
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
31
31
|
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); }
|
|
32
32
|
import { createBookingTicketModule } from "./types";
|
|
33
|
+
import { getProductExtend as getProductExtendUtil, getResourceByIds as getResourceByIdsUtil, getResourceErrors as getResourceErrorsUtil, derivePresetStartTimeFromDate } from "../../modules/BookingContext";
|
|
33
34
|
import { BaseSalesImpl } from "../BaseSales";
|
|
34
35
|
import Scan from "./utils/scan";
|
|
35
36
|
import { formatOrderCustomerPatch } from "./utils/orderCustomer";
|
|
36
37
|
import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
|
|
37
38
|
import scanCache from "./utils/scan/scanCache";
|
|
38
39
|
import { buildCartView } from "./utils/cartView";
|
|
40
|
+
import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
|
|
41
|
+
import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
|
|
42
|
+
import { buildNormalProductCacheItemFromOrderLine as buildNormalProductCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine";
|
|
39
43
|
import { applyBookingsStatus, resolveScheduleId, restoreBookingsStatus } from "./utils/bookingStatus";
|
|
40
44
|
export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
41
45
|
_inherits(BookingTicketImpl, _BaseSalesImpl);
|
|
@@ -57,16 +61,24 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
57
61
|
_defineProperty(_assertThisInitialized(_this), "platform", void 0);
|
|
58
62
|
_defineProperty(_assertThisInitialized(_this), "scan", void 0);
|
|
59
63
|
_defineProperty(_assertThisInitialized(_this), "productCatalog", []);
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshInFlight", null);
|
|
65
|
+
_defineProperty(_assertThisInitialized(_this), "orderCustomerDiscountRefreshCustomerId", null);
|
|
60
66
|
return _this;
|
|
61
67
|
}
|
|
62
68
|
_createClass(BookingTicketImpl, [{
|
|
63
69
|
key: "getRegisteredModuleNames",
|
|
64
70
|
value:
|
|
65
71
|
/**
|
|
66
|
-
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer。
|
|
72
|
+
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
73
|
+
* bookingContext 是 SalesSdk 加车下沉所需的「预约 UI 上下文」(bookingConfig / resourcesOrigin / date)。
|
|
67
74
|
*/
|
|
68
75
|
function getRegisteredModuleNames() {
|
|
69
|
-
return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer']);
|
|
76
|
+
return [].concat(_toConsumableArray(_get(_getPrototypeOf(BookingTicketImpl.prototype), "getRegisteredModuleNames", this).call(this)), ['customer', 'bookingContext']);
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "getSubmitOrderSalesChannel",
|
|
80
|
+
value: function getSubmitOrderSalesChannel() {
|
|
81
|
+
return 'pos';
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
/**
|
|
@@ -125,7 +137,8 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
125
137
|
key: "loadSalesDetail",
|
|
126
138
|
value: (function () {
|
|
127
139
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(orderIdOrParams) {
|
|
128
|
-
var
|
|
140
|
+
var _ref;
|
|
141
|
+
var sales, customerModule, detailCustomer, orderCustomerSnapshot, protocolCustomerId, protocolCustomer, selectedCustomer, _selectedCustomer$nam, _ref2, detailCustomerId, detailCustomerRest, rawId, customer;
|
|
129
142
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
130
143
|
while (1) switch (_context2.prev = _context2.next) {
|
|
131
144
|
case 0:
|
|
@@ -136,21 +149,36 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
136
149
|
console.log(sales, '1234sales');
|
|
137
150
|
customerModule = this.store.customer;
|
|
138
151
|
detailCustomer = sales === null || sales === void 0 ? void 0 : sales.customer;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
orderCustomerSnapshot = this.store.order.getOrderCustomerSnapshot();
|
|
153
|
+
protocolCustomerId = sales === null || sales === void 0 ? void 0 : sales.customer_id;
|
|
154
|
+
protocolCustomer = protocolCustomerId !== undefined && protocolCustomerId !== null ? {
|
|
155
|
+
id: protocolCustomerId,
|
|
156
|
+
name: String((sales === null || sales === void 0 ? void 0 : sales.customer_name) || ''),
|
|
157
|
+
phone: sales === null || sales === void 0 ? void 0 : sales.phone,
|
|
158
|
+
email: sales === null || sales === void 0 ? void 0 : sales.email,
|
|
159
|
+
country_calling_code: sales === null || sales === void 0 ? void 0 : sales.country_calling_code
|
|
160
|
+
} : null;
|
|
161
|
+
selectedCustomer = (_ref = detailCustomer !== null && detailCustomer !== void 0 ? detailCustomer : orderCustomerSnapshot) !== null && _ref !== void 0 ? _ref : protocolCustomer;
|
|
162
|
+
if (!(customerModule && selectedCustomer)) {
|
|
163
|
+
_context2.next = 18;
|
|
164
|
+
break;
|
|
151
165
|
}
|
|
166
|
+
_ref2 = selectedCustomer !== null && selectedCustomer !== void 0 ? selectedCustomer : {}, detailCustomerId = _ref2.id, detailCustomerRest = _objectWithoutProperties(_ref2, _excluded);
|
|
167
|
+
rawId = detailCustomerId !== null && detailCustomerId !== void 0 ? detailCustomerId : '';
|
|
168
|
+
customer = _objectSpread(_objectSpread({}, detailCustomerRest), {}, {
|
|
169
|
+
id: rawId == null ? '' : rawId,
|
|
170
|
+
name: (_selectedCustomer$nam = selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.name) !== null && _selectedCustomer$nam !== void 0 ? _selectedCustomer$nam : '',
|
|
171
|
+
phone: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.phone,
|
|
172
|
+
email: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.email,
|
|
173
|
+
country_calling_code: selectedCustomer === null || selectedCustomer === void 0 ? void 0 : selectedCustomer.country_calling_code
|
|
174
|
+
});
|
|
175
|
+
customerModule.setSelectedCustomer(customer);
|
|
176
|
+
this.setOrderCustomer(customer);
|
|
177
|
+
_context2.next = 18;
|
|
178
|
+
return this.store.order.saveDraft();
|
|
179
|
+
case 18:
|
|
152
180
|
return _context2.abrupt("return", sales);
|
|
153
|
-
case
|
|
181
|
+
case 19:
|
|
154
182
|
case "end":
|
|
155
183
|
return _context2.stop();
|
|
156
184
|
}
|
|
@@ -160,7 +188,188 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
160
188
|
return _loadSalesDetail.apply(this, arguments);
|
|
161
189
|
}
|
|
162
190
|
return loadSalesDetail;
|
|
191
|
+
}())
|
|
192
|
+
}, {
|
|
193
|
+
key: "scanPromotionCode",
|
|
194
|
+
value: function () {
|
|
195
|
+
var _scanPromotionCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(code, customerId) {
|
|
196
|
+
var raw;
|
|
197
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
198
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
if (this.store.order) {
|
|
201
|
+
_context3.next = 2;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
throw new Error('order 模块未初始化');
|
|
205
|
+
case 2:
|
|
206
|
+
_context3.next = 4;
|
|
207
|
+
return this.store.order.scanCode(code, customerId);
|
|
208
|
+
case 4:
|
|
209
|
+
raw = _context3.sent;
|
|
210
|
+
if (!raw.isAvailable) {
|
|
211
|
+
_context3.next = 11;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
_context3.next = 8;
|
|
215
|
+
return this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList);
|
|
216
|
+
case 8:
|
|
217
|
+
_context3.next = 10;
|
|
218
|
+
return this.store.order.recalculateSummary({
|
|
219
|
+
createIfMissing: true
|
|
220
|
+
});
|
|
221
|
+
case 10:
|
|
222
|
+
this.store.order.persistTempOrder();
|
|
223
|
+
case 11:
|
|
224
|
+
return _context3.abrupt("return", {
|
|
225
|
+
isAvailable: raw.isAvailable,
|
|
226
|
+
type: raw.type,
|
|
227
|
+
unavailableReason: raw.unavailableReason
|
|
228
|
+
});
|
|
229
|
+
case 12:
|
|
230
|
+
case "end":
|
|
231
|
+
return _context3.stop();
|
|
232
|
+
}
|
|
233
|
+
}, _callee3, this);
|
|
234
|
+
}));
|
|
235
|
+
function scanPromotionCode(_x3, _x4) {
|
|
236
|
+
return _scanPromotionCode.apply(this, arguments);
|
|
237
|
+
}
|
|
238
|
+
return scanPromotionCode;
|
|
163
239
|
}()
|
|
240
|
+
}, {
|
|
241
|
+
key: "hydrateOrderCustomerFromScanDiscounts",
|
|
242
|
+
value: function () {
|
|
243
|
+
var _hydrateOrderCustomerFromScanDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(discounts) {
|
|
244
|
+
var currentOrderCustomer, customerId, customer;
|
|
245
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
246
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
247
|
+
case 0:
|
|
248
|
+
currentOrderCustomer = this.store.order.getOrderCustomer();
|
|
249
|
+
if (!currentOrderCustomer) {
|
|
250
|
+
_context4.next = 3;
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
return _context4.abrupt("return");
|
|
254
|
+
case 3:
|
|
255
|
+
customerId = this.getDiscountCustomerId(discounts);
|
|
256
|
+
if (customerId) {
|
|
257
|
+
_context4.next = 6;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return _context4.abrupt("return");
|
|
261
|
+
case 6:
|
|
262
|
+
_context4.next = 8;
|
|
263
|
+
return this.resolveCustomerByDiscountCustomerId(customerId);
|
|
264
|
+
case 8:
|
|
265
|
+
customer = _context4.sent;
|
|
266
|
+
if (customer) {
|
|
267
|
+
_context4.next = 11;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
return _context4.abrupt("return");
|
|
271
|
+
case 11:
|
|
272
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
273
|
+
this.setOrderCustomer(customer);
|
|
274
|
+
case 13:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context4.stop();
|
|
277
|
+
}
|
|
278
|
+
}, _callee4, this);
|
|
279
|
+
}));
|
|
280
|
+
function hydrateOrderCustomerFromScanDiscounts(_x5) {
|
|
281
|
+
return _hydrateOrderCustomerFromScanDiscounts.apply(this, arguments);
|
|
282
|
+
}
|
|
283
|
+
return hydrateOrderCustomerFromScanDiscounts;
|
|
284
|
+
}()
|
|
285
|
+
}, {
|
|
286
|
+
key: "getDiscountCustomerId",
|
|
287
|
+
value: function getDiscountCustomerId(discounts) {
|
|
288
|
+
var discount = discounts.find(function (item) {
|
|
289
|
+
return item.customer_id != null;
|
|
290
|
+
});
|
|
291
|
+
var customerId = Number(discount === null || discount === void 0 ? void 0 : discount.customer_id);
|
|
292
|
+
if (!Number.isFinite(customerId) || customerId <= 0) return null;
|
|
293
|
+
return customerId;
|
|
294
|
+
}
|
|
295
|
+
}, {
|
|
296
|
+
key: "resolveCustomerByDiscountCustomerId",
|
|
297
|
+
value: function () {
|
|
298
|
+
var _resolveCustomerByDiscountCustomerId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(customerId) {
|
|
299
|
+
var _result$list;
|
|
300
|
+
var localCustomers, localCustomer, normalizedLocalCustomer, result, remoteCustomer;
|
|
301
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
302
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
303
|
+
case 0:
|
|
304
|
+
localCustomers = this.store.customer.getCustomers();
|
|
305
|
+
localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
306
|
+
normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
307
|
+
if (!(normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer))) {
|
|
308
|
+
_context5.next = 5;
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
return _context5.abrupt("return", normalizedLocalCustomer);
|
|
312
|
+
case 5:
|
|
313
|
+
_context5.next = 7;
|
|
314
|
+
return this.store.customer.queryCustomerList({
|
|
315
|
+
ids: [customerId],
|
|
316
|
+
skip: 1,
|
|
317
|
+
num: 1
|
|
318
|
+
});
|
|
319
|
+
case 7:
|
|
320
|
+
result = _context5.sent;
|
|
321
|
+
remoteCustomer = this.findCustomerById((result === null || result === void 0 ? void 0 : result.list) || [], customerId) || (result === null || result === void 0 || (_result$list = result.list) === null || _result$list === void 0 ? void 0 : _result$list[0]) || null;
|
|
322
|
+
return _context5.abrupt("return", remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null);
|
|
323
|
+
case 10:
|
|
324
|
+
case "end":
|
|
325
|
+
return _context5.stop();
|
|
326
|
+
}
|
|
327
|
+
}, _callee5, this);
|
|
328
|
+
}));
|
|
329
|
+
function resolveCustomerByDiscountCustomerId(_x6) {
|
|
330
|
+
return _resolveCustomerByDiscountCustomerId.apply(this, arguments);
|
|
331
|
+
}
|
|
332
|
+
return resolveCustomerByDiscountCustomerId;
|
|
333
|
+
}()
|
|
334
|
+
}, {
|
|
335
|
+
key: "findCustomerById",
|
|
336
|
+
value: function findCustomerById() {
|
|
337
|
+
var _this2 = this;
|
|
338
|
+
var customers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
339
|
+
var customerId = arguments.length > 1 ? arguments[1] : undefined;
|
|
340
|
+
return customers.find(function (customer) {
|
|
341
|
+
var rawId = _this2.getRawCustomerId(customer);
|
|
342
|
+
return rawId !== null && String(rawId) === String(customerId);
|
|
343
|
+
}) || null;
|
|
344
|
+
}
|
|
345
|
+
}, {
|
|
346
|
+
key: "normalizeCustomer",
|
|
347
|
+
value: function normalizeCustomer(customer) {
|
|
348
|
+
var _ref3, _ref4, _customer$phone, _ref5, _customer$email, _ref6, _customer$country_cal;
|
|
349
|
+
var raw = customer;
|
|
350
|
+
var rawId = this.getRawCustomerId(customer);
|
|
351
|
+
var name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(' ') || '';
|
|
352
|
+
return _objectSpread(_objectSpread({}, customer), {}, {
|
|
353
|
+
id: rawId !== null && rawId !== void 0 ? rawId : customer.id,
|
|
354
|
+
name: name,
|
|
355
|
+
phone: (_ref3 = (_ref4 = (_customer$phone = customer.phone) !== null && _customer$phone !== void 0 ? _customer$phone : raw.phone) !== null && _ref4 !== void 0 ? _ref4 : raw.mobile) !== null && _ref3 !== void 0 ? _ref3 : '',
|
|
356
|
+
email: (_ref5 = (_customer$email = customer.email) !== null && _customer$email !== void 0 ? _customer$email : raw.email) !== null && _ref5 !== void 0 ? _ref5 : '',
|
|
357
|
+
country_calling_code: (_ref6 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : raw.country_calling_code) !== null && _ref6 !== void 0 ? _ref6 : ''
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
key: "getRawCustomerId",
|
|
362
|
+
value: function getRawCustomerId(customer) {
|
|
363
|
+
var _ref7, _ref8, _customer$id;
|
|
364
|
+
var raw = customer;
|
|
365
|
+
return (_ref7 = (_ref8 = (_customer$id = customer.id) !== null && _customer$id !== void 0 ? _customer$id : raw.customer_id) !== null && _ref8 !== void 0 ? _ref8 : raw.customerId) !== null && _ref7 !== void 0 ? _ref7 : null;
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "hasUsableCustomerDetails",
|
|
369
|
+
value: function hasUsableCustomerDetails(customer) {
|
|
370
|
+
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
371
|
+
}
|
|
372
|
+
|
|
164
373
|
/**
|
|
165
374
|
* 更新当前预约的 appointment_status。
|
|
166
375
|
*
|
|
@@ -175,66 +384,65 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
175
384
|
* @param status 目标状态(如 'confirmed')
|
|
176
385
|
* @returns 接口返回的 data
|
|
177
386
|
*/
|
|
178
|
-
)
|
|
179
387
|
}, {
|
|
180
388
|
key: "setBookingStatus",
|
|
181
389
|
value: (function () {
|
|
182
|
-
var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
390
|
+
var _setBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(status) {
|
|
183
391
|
var _this$store$order, _this$store$order$get;
|
|
184
392
|
var tempOrder, orderId, scheduleId, bookings, previous, _data, res;
|
|
185
|
-
return _regeneratorRuntime().wrap(function
|
|
186
|
-
while (1) switch (
|
|
393
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
394
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
187
395
|
case 0:
|
|
188
396
|
tempOrder = (_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$get = _this$store$order.getTempOrder) === null || _this$store$order$get === void 0 ? void 0 : _this$store$order$get.call(_this$store$order);
|
|
189
397
|
if (tempOrder) {
|
|
190
|
-
|
|
398
|
+
_context6.next = 3;
|
|
191
399
|
break;
|
|
192
400
|
}
|
|
193
401
|
throw new Error('setBookingStatus: tempOrder 未加载');
|
|
194
402
|
case 3:
|
|
195
403
|
orderId = tempOrder.order_id;
|
|
196
404
|
if (!(orderId === undefined || orderId === null)) {
|
|
197
|
-
|
|
405
|
+
_context6.next = 6;
|
|
198
406
|
break;
|
|
199
407
|
}
|
|
200
408
|
throw new Error('setBookingStatus: tempOrder.order_id 缺失');
|
|
201
409
|
case 6:
|
|
202
410
|
scheduleId = resolveScheduleId(tempOrder);
|
|
203
411
|
if (!(scheduleId === null)) {
|
|
204
|
-
|
|
412
|
+
_context6.next = 9;
|
|
205
413
|
break;
|
|
206
414
|
}
|
|
207
415
|
throw new Error('setBookingStatus: 无法解析 schedule id(metadata 与 root booking 均缺失)');
|
|
208
416
|
case 9:
|
|
209
417
|
bookings = Array.isArray(tempOrder.bookings) ? tempOrder.bookings : [];
|
|
210
418
|
previous = applyBookingsStatus(bookings, status);
|
|
211
|
-
|
|
212
|
-
|
|
419
|
+
_context6.prev = 11;
|
|
420
|
+
_context6.next = 14;
|
|
213
421
|
return this.request.put("/schedule/booking/appointment-status/".concat(scheduleId), {
|
|
214
422
|
appointment_status: status
|
|
215
423
|
});
|
|
216
424
|
case 14:
|
|
217
|
-
res =
|
|
218
|
-
|
|
425
|
+
res = _context6.sent;
|
|
426
|
+
_context6.next = 17;
|
|
219
427
|
return this.refreshSalesDetail();
|
|
220
428
|
case 17:
|
|
221
429
|
this.core.effects.emit("".concat(this.name, ":onBookingStatusChange"), {
|
|
222
430
|
orderId: orderId,
|
|
223
431
|
status: status
|
|
224
432
|
});
|
|
225
|
-
return
|
|
433
|
+
return _context6.abrupt("return", (_data = res === null || res === void 0 ? void 0 : res.data) !== null && _data !== void 0 ? _data : res);
|
|
226
434
|
case 21:
|
|
227
|
-
|
|
228
|
-
|
|
435
|
+
_context6.prev = 21;
|
|
436
|
+
_context6.t0 = _context6["catch"](11);
|
|
229
437
|
restoreBookingsStatus(bookings, previous);
|
|
230
|
-
throw
|
|
438
|
+
throw _context6.t0;
|
|
231
439
|
case 25:
|
|
232
440
|
case "end":
|
|
233
|
-
return
|
|
441
|
+
return _context6.stop();
|
|
234
442
|
}
|
|
235
|
-
},
|
|
443
|
+
}, _callee6, this, [[11, 21]]);
|
|
236
444
|
}));
|
|
237
|
-
function setBookingStatus(
|
|
445
|
+
function setBookingStatus(_x7) {
|
|
238
446
|
return _setBookingStatus.apply(this, arguments);
|
|
239
447
|
}
|
|
240
448
|
return setBookingStatus;
|
|
@@ -253,35 +461,35 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
253
461
|
}, {
|
|
254
462
|
key: "refreshSalesDetail",
|
|
255
463
|
value: (function () {
|
|
256
|
-
var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
464
|
+
var _refreshSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
257
465
|
var _this$store$order2, _this$store$order2$ge;
|
|
258
466
|
var tempOrder, orderId;
|
|
259
|
-
return _regeneratorRuntime().wrap(function
|
|
260
|
-
while (1) switch (
|
|
467
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
468
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
261
469
|
case 0:
|
|
262
470
|
tempOrder = (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$ge = _this$store$order2.getTempOrder) === null || _this$store$order2$ge === void 0 ? void 0 : _this$store$order2$ge.call(_this$store$order2);
|
|
263
471
|
if (tempOrder) {
|
|
264
|
-
|
|
472
|
+
_context7.next = 3;
|
|
265
473
|
break;
|
|
266
474
|
}
|
|
267
475
|
throw new Error('refreshSalesDetail: tempOrder 未加载');
|
|
268
476
|
case 3:
|
|
269
477
|
orderId = tempOrder.order_id;
|
|
270
478
|
if (!(orderId === undefined || orderId === null)) {
|
|
271
|
-
|
|
479
|
+
_context7.next = 6;
|
|
272
480
|
break;
|
|
273
481
|
}
|
|
274
482
|
throw new Error('refreshSalesDetail: tempOrder.order_id 缺失');
|
|
275
483
|
case 6:
|
|
276
|
-
return
|
|
484
|
+
return _context7.abrupt("return", this.loadSalesDetail({
|
|
277
485
|
orderId: Number(orderId),
|
|
278
486
|
forceRemote: true
|
|
279
487
|
}));
|
|
280
488
|
case 7:
|
|
281
489
|
case "end":
|
|
282
|
-
return
|
|
490
|
+
return _context7.stop();
|
|
283
491
|
}
|
|
284
|
-
},
|
|
492
|
+
}, _callee7, this);
|
|
285
493
|
}));
|
|
286
494
|
function refreshSalesDetail() {
|
|
287
495
|
return _refreshSalesDetail.apply(this, arguments);
|
|
@@ -297,44 +505,50 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
297
505
|
}, {
|
|
298
506
|
key: "loadProducts",
|
|
299
507
|
value: (function () {
|
|
300
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
508
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
301
509
|
var params,
|
|
302
510
|
options,
|
|
303
511
|
schedule_date,
|
|
304
512
|
customer_id,
|
|
305
513
|
menu_list_ids,
|
|
306
514
|
schedule_datetime,
|
|
515
|
+
bookingDate,
|
|
307
516
|
_result,
|
|
308
|
-
|
|
309
|
-
return _regeneratorRuntime().wrap(function
|
|
310
|
-
while (1) switch (
|
|
517
|
+
_args8 = arguments;
|
|
518
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
519
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
311
520
|
case 0:
|
|
312
|
-
params =
|
|
313
|
-
options =
|
|
314
|
-
schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime;
|
|
315
|
-
|
|
316
|
-
|
|
521
|
+
params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
|
|
522
|
+
options = _args8.length > 1 ? _args8[1] : undefined;
|
|
523
|
+
schedule_date = params.schedule_date, customer_id = params.customer_id, menu_list_ids = params.menu_list_ids, schedule_datetime = params.schedule_datetime; // 优先写入 schedule_datetime(含时分),供加购 presetStartTime 与 TimeBar 对齐;
|
|
524
|
+
// requiresDetail 弹窗仍通过 formatBookingDateForUI 只取日历日 YYYY-MM-DD。
|
|
525
|
+
bookingDate = schedule_datetime || schedule_date || '';
|
|
526
|
+
if (bookingDate) {
|
|
527
|
+
this.setBookingDate(bookingDate);
|
|
528
|
+
}
|
|
529
|
+
_context8.prev = 5;
|
|
530
|
+
_context8.next = 8;
|
|
317
531
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
318
532
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
319
533
|
with_schedule: 1
|
|
320
534
|
}, params), {}, {
|
|
321
535
|
cacheId: this.cacheId
|
|
322
536
|
}), options);
|
|
323
|
-
case
|
|
324
|
-
_result =
|
|
537
|
+
case 8:
|
|
538
|
+
_result = _context8.sent;
|
|
325
539
|
this.productCatalog = Array.isArray(_result) ? _toConsumableArray(_result) : [];
|
|
326
540
|
this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), _result);
|
|
327
|
-
return
|
|
328
|
-
case
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
console.error('Failed to load products:',
|
|
332
|
-
throw
|
|
333
|
-
case
|
|
541
|
+
return _context8.abrupt("return", _result);
|
|
542
|
+
case 14:
|
|
543
|
+
_context8.prev = 14;
|
|
544
|
+
_context8.t0 = _context8["catch"](5);
|
|
545
|
+
console.error('Failed to load products:', _context8.t0);
|
|
546
|
+
throw _context8.t0;
|
|
547
|
+
case 18:
|
|
334
548
|
case "end":
|
|
335
|
-
return
|
|
549
|
+
return _context8.stop();
|
|
336
550
|
}
|
|
337
|
-
},
|
|
551
|
+
}, _callee8, this, [[5, 14]]);
|
|
338
552
|
}));
|
|
339
553
|
function loadProducts() {
|
|
340
554
|
return _loadProducts.apply(this, arguments);
|
|
@@ -349,28 +563,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
349
563
|
}, {
|
|
350
564
|
key: "loadProductDetail",
|
|
351
565
|
value: (function () {
|
|
352
|
-
var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
566
|
+
var _loadProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params, options) {
|
|
353
567
|
var product_id, queryParams, products;
|
|
354
|
-
return _regeneratorRuntime().wrap(function
|
|
355
|
-
while (1) switch (
|
|
568
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
569
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
356
570
|
case 0:
|
|
357
571
|
product_id = params.product_id, queryParams = _objectWithoutProperties(params, _excluded2);
|
|
358
|
-
|
|
572
|
+
_context9.next = 3;
|
|
359
573
|
return this.loadProducts(_objectSpread(_objectSpread({}, queryParams), {}, {
|
|
360
574
|
product_ids: [product_id]
|
|
361
575
|
}), options);
|
|
362
576
|
case 3:
|
|
363
|
-
products =
|
|
364
|
-
return
|
|
577
|
+
products = _context9.sent;
|
|
578
|
+
return _context9.abrupt("return", products.find(function (product) {
|
|
365
579
|
return Number(product.id) === Number(product_id);
|
|
366
580
|
}));
|
|
367
581
|
case 5:
|
|
368
582
|
case "end":
|
|
369
|
-
return
|
|
583
|
+
return _context9.stop();
|
|
370
584
|
}
|
|
371
|
-
},
|
|
585
|
+
}, _callee9, this);
|
|
372
586
|
}));
|
|
373
|
-
function loadProductDetail(
|
|
587
|
+
function loadProductDetail(_x8, _x9) {
|
|
374
588
|
return _loadProductDetail.apply(this, arguments);
|
|
375
589
|
}
|
|
376
590
|
return loadProductDetail;
|
|
@@ -403,16 +617,16 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
403
617
|
}, {
|
|
404
618
|
key: "getProducts",
|
|
405
619
|
value: (function () {
|
|
406
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
407
|
-
return _regeneratorRuntime().wrap(function
|
|
408
|
-
while (1) switch (
|
|
620
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
621
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
622
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
409
623
|
case 0:
|
|
410
|
-
return
|
|
624
|
+
return _context10.abrupt("return", this.store.products.getProducts());
|
|
411
625
|
case 1:
|
|
412
626
|
case "end":
|
|
413
|
-
return
|
|
627
|
+
return _context10.stop();
|
|
414
628
|
}
|
|
415
|
-
},
|
|
629
|
+
}, _callee10, this);
|
|
416
630
|
}));
|
|
417
631
|
function getProducts() {
|
|
418
632
|
return _getProducts.apply(this, arguments);
|
|
@@ -465,18 +679,18 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
465
679
|
}, {
|
|
466
680
|
key: "getProductByIds",
|
|
467
681
|
value: (function () {
|
|
468
|
-
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
469
|
-
return _regeneratorRuntime().wrap(function
|
|
470
|
-
while (1) switch (
|
|
682
|
+
var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ids) {
|
|
683
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
684
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
471
685
|
case 0:
|
|
472
|
-
return
|
|
686
|
+
return _context11.abrupt("return", this.store.products.getProductByIds(ids));
|
|
473
687
|
case 1:
|
|
474
688
|
case "end":
|
|
475
|
-
return
|
|
689
|
+
return _context11.stop();
|
|
476
690
|
}
|
|
477
|
-
},
|
|
691
|
+
}, _callee11, this);
|
|
478
692
|
}));
|
|
479
|
-
function getProductByIds(
|
|
693
|
+
function getProductByIds(_x10) {
|
|
480
694
|
return _getProductByIds.apply(this, arguments);
|
|
481
695
|
}
|
|
482
696
|
return getProductByIds;
|
|
@@ -490,27 +704,27 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
490
704
|
}, {
|
|
491
705
|
key: "getScheduleTimePoints",
|
|
492
706
|
value: (function () {
|
|
493
|
-
var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
707
|
+
var _getScheduleTimePoints = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
494
708
|
var result;
|
|
495
|
-
return _regeneratorRuntime().wrap(function
|
|
496
|
-
while (1) switch (
|
|
709
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
710
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
497
711
|
case 0:
|
|
498
|
-
|
|
712
|
+
_context12.next = 2;
|
|
499
713
|
return this.request.post('/menu/schedule-time-points', {
|
|
500
714
|
menu_list_ids: params.menu_list_ids
|
|
501
715
|
}, {
|
|
502
716
|
osServer: true
|
|
503
717
|
});
|
|
504
718
|
case 2:
|
|
505
|
-
result =
|
|
506
|
-
return
|
|
719
|
+
result = _context12.sent;
|
|
720
|
+
return _context12.abrupt("return", result.data || []);
|
|
507
721
|
case 4:
|
|
508
722
|
case "end":
|
|
509
|
-
return
|
|
723
|
+
return _context12.stop();
|
|
510
724
|
}
|
|
511
|
-
},
|
|
725
|
+
}, _callee12, this);
|
|
512
726
|
}));
|
|
513
|
-
function getScheduleTimePoints(
|
|
727
|
+
function getScheduleTimePoints(_x11) {
|
|
514
728
|
return _getScheduleTimePoints.apply(this, arguments);
|
|
515
729
|
}
|
|
516
730
|
return getScheduleTimePoints;
|
|
@@ -524,30 +738,30 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
524
738
|
}, {
|
|
525
739
|
key: "getCustomerList",
|
|
526
740
|
value: (function () {
|
|
527
|
-
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
741
|
+
var _getCustomerList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
528
742
|
var params,
|
|
529
743
|
_result2,
|
|
530
|
-
|
|
531
|
-
return _regeneratorRuntime().wrap(function
|
|
532
|
-
while (1) switch (
|
|
744
|
+
_args13 = arguments;
|
|
745
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
746
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
533
747
|
case 0:
|
|
534
|
-
params =
|
|
535
|
-
|
|
536
|
-
|
|
748
|
+
params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
|
|
749
|
+
_context13.prev = 1;
|
|
750
|
+
_context13.next = 4;
|
|
537
751
|
return this.store.customer.getCustomerList(params);
|
|
538
752
|
case 4:
|
|
539
|
-
_result2 =
|
|
540
|
-
return
|
|
753
|
+
_result2 = _context13.sent;
|
|
754
|
+
return _context13.abrupt("return", _result2);
|
|
541
755
|
case 8:
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
console.error('Failed to get customer list:',
|
|
545
|
-
throw
|
|
756
|
+
_context13.prev = 8;
|
|
757
|
+
_context13.t0 = _context13["catch"](1);
|
|
758
|
+
console.error('Failed to get customer list:', _context13.t0);
|
|
759
|
+
throw _context13.t0;
|
|
546
760
|
case 12:
|
|
547
761
|
case "end":
|
|
548
|
-
return
|
|
762
|
+
return _context13.stop();
|
|
549
763
|
}
|
|
550
|
-
},
|
|
764
|
+
}, _callee13, this, [[1, 8]]);
|
|
551
765
|
}));
|
|
552
766
|
function getCustomerList() {
|
|
553
767
|
return _getCustomerList.apply(this, arguments);
|
|
@@ -654,14 +868,21 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
654
868
|
}, {
|
|
655
869
|
key: "setOrderCustomer",
|
|
656
870
|
value: function setOrderCustomer(customer) {
|
|
871
|
+
var _this$store$order$get3;
|
|
657
872
|
if (!customer) {
|
|
658
873
|
this.clearOrderCustomer();
|
|
659
874
|
return;
|
|
660
875
|
}
|
|
876
|
+
var previousCustomerId = (_this$store$order$get3 = this.store.order.getOrderCustomer()) === null || _this$store$order$get3 === void 0 ? void 0 : _this$store$order$get3.customer_id;
|
|
661
877
|
var patch = formatOrderCustomerPatch(customer);
|
|
878
|
+
if (Number(previousCustomerId || 0) !== Number(patch.customer_id || 0)) {
|
|
879
|
+
this.discountConfigCacheKey = null;
|
|
880
|
+
this.hasManualDiscountSelection = false;
|
|
881
|
+
}
|
|
662
882
|
this.store.order.setOrderCustomer(patch, customer);
|
|
663
883
|
var next = this.buildOrderCustomerPayload();
|
|
664
884
|
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), next);
|
|
885
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
665
886
|
}
|
|
666
887
|
|
|
667
888
|
/**
|
|
@@ -688,11 +909,63 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
688
909
|
}, {
|
|
689
910
|
key: "clearOrderCustomer",
|
|
690
911
|
value: function clearOrderCustomer() {
|
|
912
|
+
var _discountModule$setOr,
|
|
913
|
+
_discountModule$setDi,
|
|
914
|
+
_this3 = this;
|
|
691
915
|
this.store.order.clearOrderCustomer();
|
|
916
|
+
this.discountConfigCacheKey = null;
|
|
917
|
+
this.hasManualDiscountSelection = false;
|
|
918
|
+
var orderStore = this.store.order.store || {};
|
|
919
|
+
var discountModule = orderStore.discount;
|
|
920
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, []));
|
|
921
|
+
void (discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, []));
|
|
922
|
+
this.store.order.applyDiscount();
|
|
923
|
+
void this.store.order.recalculateSummary({
|
|
924
|
+
createIfMissing: true
|
|
925
|
+
}).then(function () {
|
|
926
|
+
return _this3.store.order.persistTempOrder();
|
|
927
|
+
}).catch(function (error) {
|
|
928
|
+
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
929
|
+
});
|
|
692
930
|
this.core.effects.emit("".concat(this.name, ":onOrderCustomerChange"), null);
|
|
693
931
|
}
|
|
694
932
|
|
|
695
|
-
/**
|
|
933
|
+
/**
|
|
934
|
+
* 重置 tempOrder,并同步清空下单客户运行态。
|
|
935
|
+
*
|
|
936
|
+
* OrderModule.restoreOrder 会重建空单(customer_id 已为 null),但不会:
|
|
937
|
+
* - emit BookingTicket `onOrderCustomerChange`
|
|
938
|
+
* - 重置 CustomerModule.selectedCustomer(老路 getActiveCustomer)
|
|
939
|
+
*
|
|
940
|
+
* 因此在 super.restoreOrder 之后显式清客户,保证 SalesSdk / ticketBooking 订阅方与 tempOrder 一致。
|
|
941
|
+
*/
|
|
942
|
+
}, {
|
|
943
|
+
key: "restoreOrder",
|
|
944
|
+
value: (function () {
|
|
945
|
+
var _restoreOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
946
|
+
var _this$store$customer;
|
|
947
|
+
var tempOrder;
|
|
948
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
949
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
950
|
+
case 0:
|
|
951
|
+
_context14.next = 2;
|
|
952
|
+
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "restoreOrder", this).call(this);
|
|
953
|
+
case 2:
|
|
954
|
+
tempOrder = _context14.sent;
|
|
955
|
+
this.clearOrderCustomer();
|
|
956
|
+
(_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || _this$store$customer.setSelectedCustomer(null);
|
|
957
|
+
return _context14.abrupt("return", tempOrder);
|
|
958
|
+
case 6:
|
|
959
|
+
case "end":
|
|
960
|
+
return _context14.stop();
|
|
961
|
+
}
|
|
962
|
+
}, _callee14, this);
|
|
963
|
+
}));
|
|
964
|
+
function restoreOrder() {
|
|
965
|
+
return _restoreOrder.apply(this, arguments);
|
|
966
|
+
}
|
|
967
|
+
return restoreOrder;
|
|
968
|
+
}() /** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */)
|
|
696
969
|
}, {
|
|
697
970
|
key: "buildOrderCustomerPayload",
|
|
698
971
|
value: function buildOrderCustomerPayload() {
|
|
@@ -703,6 +976,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
703
976
|
snapshot: this.store.order.getOrderCustomerSnapshot()
|
|
704
977
|
};
|
|
705
978
|
}
|
|
979
|
+
}, {
|
|
980
|
+
key: "refreshDiscountConfigAfterOrderCustomerChange",
|
|
981
|
+
value: function refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
982
|
+
var _this4 = this;
|
|
983
|
+
if (!customerId || customerId === 1) return;
|
|
984
|
+
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
var previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
988
|
+
var refreshTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
989
|
+
var currentCustomer;
|
|
990
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
991
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
992
|
+
case 0:
|
|
993
|
+
if (!previousRefresh) {
|
|
994
|
+
_context15.next = 3;
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
_context15.next = 3;
|
|
998
|
+
return previousRefresh.catch(function () {
|
|
999
|
+
return undefined;
|
|
1000
|
+
});
|
|
1001
|
+
case 3:
|
|
1002
|
+
currentCustomer = _this4.store.order.getOrderCustomer();
|
|
1003
|
+
if (!(!currentCustomer || Number(currentCustomer.customer_id) !== customerId)) {
|
|
1004
|
+
_context15.next = 6;
|
|
1005
|
+
break;
|
|
1006
|
+
}
|
|
1007
|
+
return _context15.abrupt("return");
|
|
1008
|
+
case 6:
|
|
1009
|
+
_context15.next = 8;
|
|
1010
|
+
return _this4.loadDiscountConfig({
|
|
1011
|
+
customerId: customerId
|
|
1012
|
+
});
|
|
1013
|
+
case 8:
|
|
1014
|
+
case "end":
|
|
1015
|
+
return _context15.stop();
|
|
1016
|
+
}
|
|
1017
|
+
}, _callee15);
|
|
1018
|
+
}))();
|
|
1019
|
+
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
1020
|
+
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
1021
|
+
refreshTask.catch(function (error) {
|
|
1022
|
+
console.error('Failed to load discount config after customer change:', error);
|
|
1023
|
+
}).finally(function () {
|
|
1024
|
+
if (_this4.orderCustomerDiscountRefreshInFlight !== refreshTask) return;
|
|
1025
|
+
_this4.orderCustomerDiscountRefreshInFlight = null;
|
|
1026
|
+
_this4.orderCustomerDiscountRefreshCustomerId = null;
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
706
1029
|
|
|
707
1030
|
/**
|
|
708
1031
|
* 获取客户分页信息
|
|
@@ -744,29 +1067,29 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
744
1067
|
}, {
|
|
745
1068
|
key: "changeCustomerPage",
|
|
746
1069
|
value: (function () {
|
|
747
|
-
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1070
|
+
var _changeCustomerPage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(page, pageSize) {
|
|
748
1071
|
var _result3;
|
|
749
|
-
return _regeneratorRuntime().wrap(function
|
|
750
|
-
while (1) switch (
|
|
1072
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1073
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
751
1074
|
case 0:
|
|
752
|
-
|
|
753
|
-
|
|
1075
|
+
_context16.prev = 0;
|
|
1076
|
+
_context16.next = 3;
|
|
754
1077
|
return this.store.customer.changeCustomerPage(page, pageSize);
|
|
755
1078
|
case 3:
|
|
756
|
-
_result3 =
|
|
757
|
-
return
|
|
1079
|
+
_result3 = _context16.sent;
|
|
1080
|
+
return _context16.abrupt("return", _result3);
|
|
758
1081
|
case 7:
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
console.error('Failed to change customer page:',
|
|
762
|
-
throw
|
|
1082
|
+
_context16.prev = 7;
|
|
1083
|
+
_context16.t0 = _context16["catch"](0);
|
|
1084
|
+
console.error('Failed to change customer page:', _context16.t0);
|
|
1085
|
+
throw _context16.t0;
|
|
763
1086
|
case 11:
|
|
764
1087
|
case "end":
|
|
765
|
-
return
|
|
1088
|
+
return _context16.stop();
|
|
766
1089
|
}
|
|
767
|
-
},
|
|
1090
|
+
}, _callee16, this, [[0, 7]]);
|
|
768
1091
|
}));
|
|
769
|
-
function changeCustomerPage(
|
|
1092
|
+
function changeCustomerPage(_x12, _x13) {
|
|
770
1093
|
return _changeCustomerPage.apply(this, arguments);
|
|
771
1094
|
}
|
|
772
1095
|
return changeCustomerPage;
|
|
@@ -779,28 +1102,28 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
779
1102
|
}, {
|
|
780
1103
|
key: "loadMoreCustomers",
|
|
781
1104
|
value: (function () {
|
|
782
|
-
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1105
|
+
var _loadMoreCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
783
1106
|
var _result4;
|
|
784
|
-
return _regeneratorRuntime().wrap(function
|
|
785
|
-
while (1) switch (
|
|
1107
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1108
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
786
1109
|
case 0:
|
|
787
|
-
|
|
788
|
-
|
|
1110
|
+
_context17.prev = 0;
|
|
1111
|
+
_context17.next = 3;
|
|
789
1112
|
return this.store.customer.loadMoreCustomers();
|
|
790
1113
|
case 3:
|
|
791
|
-
_result4 =
|
|
1114
|
+
_result4 = _context17.sent;
|
|
792
1115
|
this.core.effects.emit("".concat(this.name, ":onCustomerListUpdate"), _result4);
|
|
793
|
-
return
|
|
1116
|
+
return _context17.abrupt("return", _result4);
|
|
794
1117
|
case 8:
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
console.error('Failed to load more customers:',
|
|
798
|
-
throw
|
|
1118
|
+
_context17.prev = 8;
|
|
1119
|
+
_context17.t0 = _context17["catch"](0);
|
|
1120
|
+
console.error('Failed to load more customers:', _context17.t0);
|
|
1121
|
+
throw _context17.t0;
|
|
799
1122
|
case 12:
|
|
800
1123
|
case "end":
|
|
801
|
-
return
|
|
1124
|
+
return _context17.stop();
|
|
802
1125
|
}
|
|
803
|
-
},
|
|
1126
|
+
}, _callee17, this, [[0, 8]]);
|
|
804
1127
|
}));
|
|
805
1128
|
function loadMoreCustomers() {
|
|
806
1129
|
return _loadMoreCustomers.apply(this, arguments);
|
|
@@ -816,31 +1139,31 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
816
1139
|
}, {
|
|
817
1140
|
key: "resetAndLoadCustomers",
|
|
818
1141
|
value: (function () {
|
|
819
|
-
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1142
|
+
var _resetAndLoadCustomers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
820
1143
|
var params,
|
|
821
1144
|
_result5,
|
|
822
|
-
|
|
823
|
-
return _regeneratorRuntime().wrap(function
|
|
824
|
-
while (1) switch (
|
|
1145
|
+
_args18 = arguments;
|
|
1146
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1147
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
825
1148
|
case 0:
|
|
826
|
-
params =
|
|
827
|
-
|
|
828
|
-
|
|
1149
|
+
params = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {};
|
|
1150
|
+
_context18.prev = 1;
|
|
1151
|
+
_context18.next = 4;
|
|
829
1152
|
return this.store.customer.resetAndLoadCustomers(params);
|
|
830
1153
|
case 4:
|
|
831
|
-
_result5 =
|
|
1154
|
+
_result5 = _context18.sent;
|
|
832
1155
|
this.core.effects.emit("".concat(this.name, ":onCustomerListReset"), _result5);
|
|
833
|
-
return
|
|
1156
|
+
return _context18.abrupt("return", _result5);
|
|
834
1157
|
case 9:
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
console.error('Failed to reset and load customers:',
|
|
838
|
-
throw
|
|
1158
|
+
_context18.prev = 9;
|
|
1159
|
+
_context18.t0 = _context18["catch"](1);
|
|
1160
|
+
console.error('Failed to reset and load customers:', _context18.t0);
|
|
1161
|
+
throw _context18.t0;
|
|
839
1162
|
case 13:
|
|
840
1163
|
case "end":
|
|
841
|
-
return
|
|
1164
|
+
return _context18.stop();
|
|
842
1165
|
}
|
|
843
|
-
},
|
|
1166
|
+
}, _callee18, this, [[1, 9]]);
|
|
844
1167
|
}));
|
|
845
1168
|
function resetAndLoadCustomers() {
|
|
846
1169
|
return _resetAndLoadCustomers.apply(this, arguments);
|
|
@@ -885,9 +1208,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
885
1208
|
}, {
|
|
886
1209
|
key: "scanGlobalListener",
|
|
887
1210
|
value: function scanGlobalListener(callback) {
|
|
888
|
-
var
|
|
1211
|
+
var _this5 = this;
|
|
889
1212
|
var localSearch = function localSearch(v) {
|
|
890
|
-
return
|
|
1213
|
+
return _this5.store.products.findProductsByCodeOrBarcode(v);
|
|
891
1214
|
};
|
|
892
1215
|
var scanCallback = handleGlobalScan(this.request, localSearch);
|
|
893
1216
|
var safeCallback = function safeCallback(d) {
|
|
@@ -1002,15 +1325,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1002
1325
|
}, {
|
|
1003
1326
|
key: "setOtherParams",
|
|
1004
1327
|
value: (function () {
|
|
1005
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1006
|
-
var
|
|
1007
|
-
|
|
1328
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1329
|
+
var _ref10,
|
|
1330
|
+
_ref10$cover,
|
|
1008
1331
|
cover,
|
|
1009
|
-
|
|
1010
|
-
return _regeneratorRuntime().wrap(function
|
|
1011
|
-
while (1) switch (
|
|
1332
|
+
_args19 = arguments;
|
|
1333
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1334
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1012
1335
|
case 0:
|
|
1013
|
-
|
|
1336
|
+
_ref10 = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {}, _ref10$cover = _ref10.cover, cover = _ref10$cover === void 0 ? false : _ref10$cover;
|
|
1014
1337
|
if (cover) {
|
|
1015
1338
|
this.otherParams = params;
|
|
1016
1339
|
} else {
|
|
@@ -1018,11 +1341,11 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1018
1341
|
}
|
|
1019
1342
|
case 2:
|
|
1020
1343
|
case "end":
|
|
1021
|
-
return
|
|
1344
|
+
return _context19.stop();
|
|
1022
1345
|
}
|
|
1023
|
-
},
|
|
1346
|
+
}, _callee19, this);
|
|
1024
1347
|
}));
|
|
1025
|
-
function setOtherParams(
|
|
1348
|
+
function setOtherParams(_x14) {
|
|
1026
1349
|
return _setOtherParams.apply(this, arguments);
|
|
1027
1350
|
}
|
|
1028
1351
|
return setOtherParams;
|
|
@@ -1035,21 +1358,299 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1035
1358
|
}, {
|
|
1036
1359
|
key: "getOtherParams",
|
|
1037
1360
|
value: (function () {
|
|
1038
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1039
|
-
return _regeneratorRuntime().wrap(function
|
|
1040
|
-
while (1) switch (
|
|
1361
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1362
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1363
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1041
1364
|
case 0:
|
|
1042
|
-
return
|
|
1365
|
+
return _context20.abrupt("return", this.otherParams);
|
|
1043
1366
|
case 1:
|
|
1044
1367
|
case "end":
|
|
1045
|
-
return
|
|
1368
|
+
return _context20.stop();
|
|
1046
1369
|
}
|
|
1047
|
-
},
|
|
1370
|
+
}, _callee20, this);
|
|
1048
1371
|
}));
|
|
1049
1372
|
function getOtherParams() {
|
|
1050
1373
|
return _getOtherParams.apply(this, arguments);
|
|
1051
1374
|
}
|
|
1052
1375
|
return getOtherParams;
|
|
1376
|
+
}() // ─── BookingContext API(透传给 BookingContextModule) ──────────────────────
|
|
1377
|
+
// SalesSdkProvider 挂载时默认调 initBookingContext;也可由 UI 显式 set* 灌入已有数据。
|
|
1378
|
+
/** 拉取 board config 并写入 BookingContext。 */
|
|
1379
|
+
)
|
|
1380
|
+
}, {
|
|
1381
|
+
key: "loadBookingConfig",
|
|
1382
|
+
value: function loadBookingConfig(params) {
|
|
1383
|
+
return this.store.bookingContext.loadBookingConfig(params);
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
/** 拉取资源全集并写入 BookingContext。 */
|
|
1387
|
+
}, {
|
|
1388
|
+
key: "loadBookingResources",
|
|
1389
|
+
value: function loadBookingResources(params) {
|
|
1390
|
+
return this.store.bookingContext.loadResources(params);
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
/** 初始化 BookingContext(date + config + resources)。 */
|
|
1394
|
+
}, {
|
|
1395
|
+
key: "initBookingContext",
|
|
1396
|
+
value: function initBookingContext(params) {
|
|
1397
|
+
return this.store.bookingContext.initBookingContext(params);
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/** 当前 store 是否已具备与入参等价的 config / resources(无需再请求接口)。 */
|
|
1401
|
+
}, {
|
|
1402
|
+
key: "isBookingContextReady",
|
|
1403
|
+
value: function isBookingContextReady(params) {
|
|
1404
|
+
return this.store.bookingContext.isBookingContextReady(params);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/** 写入 booking config(来源:`/core/board/management/config`)。 */
|
|
1408
|
+
}, {
|
|
1409
|
+
key: "setBookingConfig",
|
|
1410
|
+
value: function setBookingConfig(config) {
|
|
1411
|
+
this.store.bookingContext.setBookingConfig(config);
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
/** 读取当前 booking config。 */
|
|
1415
|
+
}, {
|
|
1416
|
+
key: "getBookingConfig",
|
|
1417
|
+
value: function getBookingConfig() {
|
|
1418
|
+
return this.store.bookingContext.getBookingConfig();
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
/** 写入资源全集(来源:`/form/schedule`),同步派生 resourcesOriginMap。 */
|
|
1422
|
+
}, {
|
|
1423
|
+
key: "setResources",
|
|
1424
|
+
value: function setResources(resources) {
|
|
1425
|
+
this.store.bookingContext.setResources(resources);
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
/** 读取资源全集(浅克隆)。 */
|
|
1429
|
+
}, {
|
|
1430
|
+
key: "getResourcesOrigin",
|
|
1431
|
+
value: function getResourcesOrigin() {
|
|
1432
|
+
return this.store.bookingContext.getResourcesOrigin();
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/** 读取资源全集 map(id → resource)。 */
|
|
1436
|
+
}, {
|
|
1437
|
+
key: "getResourcesOriginMap",
|
|
1438
|
+
value: function getResourcesOriginMap() {
|
|
1439
|
+
return this.store.bookingContext.getResourcesOriginMap();
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/** 写入当前选择的日期;支持 dayjs / Date / string。 */
|
|
1443
|
+
}, {
|
|
1444
|
+
key: "setBookingDate",
|
|
1445
|
+
value: function setBookingDate(date) {
|
|
1446
|
+
this.store.bookingContext.setDate(date);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/** 读取当前选择的日期(统一 string)。 */
|
|
1450
|
+
}, {
|
|
1451
|
+
key: "getBookingDate",
|
|
1452
|
+
value: function getBookingDate() {
|
|
1453
|
+
return this.store.bookingContext.getDate();
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
/** 读取 BookingContext 完整 store(调试 / 测试 / 透传给 SDK 使用)。 */
|
|
1457
|
+
}, {
|
|
1458
|
+
key: "getBookingContextState",
|
|
1459
|
+
value: function getBookingContextState() {
|
|
1460
|
+
return this.store.bookingContext.getState();
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
/** 清空 BookingContext(切租户 / destroy 场景)。 */
|
|
1464
|
+
}, {
|
|
1465
|
+
key: "clearBookingContext",
|
|
1466
|
+
value: function clearBookingContext() {
|
|
1467
|
+
this.store.bookingContext.clear();
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
/**
|
|
1471
|
+
* 构造 BookingContext 计算上下文(供 getProductExtend / getResourceByIds 等读 API 复用)。
|
|
1472
|
+
*/
|
|
1473
|
+
}, {
|
|
1474
|
+
key: "buildBookingCalcContext",
|
|
1475
|
+
value: function buildBookingCalcContext(extra) {
|
|
1476
|
+
var _extra$date, _extra$presetStartTim;
|
|
1477
|
+
var state = this.store.bookingContext.getState();
|
|
1478
|
+
var date = (_extra$date = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date !== void 0 ? _extra$date : state.date;
|
|
1479
|
+
return _objectSpread({
|
|
1480
|
+
bookingConfig: state.bookingConfig,
|
|
1481
|
+
resourcesOrigin: state.resourcesOrigin,
|
|
1482
|
+
resourcesOriginMap: state.resourcesOriginMap,
|
|
1483
|
+
date: date,
|
|
1484
|
+
presetStartTime: (_extra$presetStartTim = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim !== void 0 ? _extra$presetStartTim : derivePresetStartTimeFromDate(date)
|
|
1485
|
+
}, extra || {});
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* 取商品当前可选资源列表(透传 OS BookingContext utils#getResourceByIds)。
|
|
1490
|
+
* `extraResources` 用于把拖入未绑定的资源也展示出来。
|
|
1491
|
+
*/
|
|
1492
|
+
}, {
|
|
1493
|
+
key: "getResourcesForProduct",
|
|
1494
|
+
value: function getResourcesForProduct(product, options) {
|
|
1495
|
+
var _ctx$bookingConfig;
|
|
1496
|
+
var ctx = this.buildBookingCalcContext();
|
|
1497
|
+
return getResourceByIdsUtil(ctx.resourcesOriginMap || {}, product, {
|
|
1498
|
+
resourceTab: (_ctx$bookingConfig = ctx.bookingConfig) === null || _ctx$bookingConfig === void 0 || (_ctx$bookingConfig = _ctx$bookingConfig.config) === null || _ctx$bookingConfig === void 0 ? void 0 : _ctx$bookingConfig.resource_tab,
|
|
1499
|
+
resourcesOrigin: ctx.resourcesOrigin,
|
|
1500
|
+
extraResources: (options === null || options === void 0 ? void 0 : options.extraResources) || []
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* 拼装 cacheItem 的 _extend / _data(资源 / 容量 / timeObj),与 info2 `getProductExtend` 等价。
|
|
1506
|
+
*/
|
|
1507
|
+
}, {
|
|
1508
|
+
key: "getProductExtend",
|
|
1509
|
+
value: function getProductExtend(cacheItem, extra) {
|
|
1510
|
+
return getProductExtendUtil({
|
|
1511
|
+
cacheItem: cacheItem,
|
|
1512
|
+
ctx: this.buildBookingCalcContext(extra)
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* 取资源不可用原因列表(结构化 enum + params,i18n 文案由 UI 渲染)。
|
|
1518
|
+
*/
|
|
1519
|
+
}, {
|
|
1520
|
+
key: "getResourceErrors",
|
|
1521
|
+
value: function getResourceErrors(resource, cacheItem) {
|
|
1522
|
+
return getResourceErrorsUtil(resource, cacheItem);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
// ─── addProduct 决策 / 转换 API(SDK 加车下沉所需) ─────────────────────────
|
|
1526
|
+
// 这一组方法是 SalesSdkCartContext.addProduct / confirmDetail 的 OS 后端。
|
|
1527
|
+
// 调用方传入 ProductData,OS 自取 bookingContext / customer / date 等上下文,
|
|
1528
|
+
// 输出 (a) autoClose 决策结果或 (b) `{ product, booking }` 协议入参。
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* 拼装 addProductDecision 通用上下文(从 store 自取)。
|
|
1532
|
+
*/
|
|
1533
|
+
}, {
|
|
1534
|
+
key: "buildAddProductCtx",
|
|
1535
|
+
value: function buildAddProductCtx(extra) {
|
|
1536
|
+
var _extra$date2, _ref11, _this$getOrderCustome, _this$getOrderCustome2, _this$store$order$get4, _extra$presetStartTim2;
|
|
1537
|
+
var bookingContextState = this.store.bookingContext.getState();
|
|
1538
|
+
var date = (_extra$date2 = extra === null || extra === void 0 ? void 0 : extra.date) !== null && _extra$date2 !== void 0 ? _extra$date2 : bookingContextState.date;
|
|
1539
|
+
var orderCustomerId = (_ref11 = (_this$getOrderCustome = (_this$getOrderCustome2 = this.getOrderCustomerSnapshot()) === null || _this$getOrderCustome2 === void 0 ? void 0 : _this$getOrderCustome2.id) !== null && _this$getOrderCustome !== void 0 ? _this$getOrderCustome : (_this$store$order$get4 = this.store.order.getTempOrder()) === null || _this$store$order$get4 === void 0 ? void 0 : _this$store$order$get4.customer_id) !== null && _ref11 !== void 0 ? _ref11 : undefined;
|
|
1540
|
+
return _objectSpread({
|
|
1541
|
+
bookingConfig: bookingContextState.bookingConfig,
|
|
1542
|
+
resourcesOrigin: bookingContextState.resourcesOrigin,
|
|
1543
|
+
resourcesOriginMap: bookingContextState.resourcesOriginMap,
|
|
1544
|
+
date: date,
|
|
1545
|
+
presetStartTime: (_extra$presetStartTim2 = extra === null || extra === void 0 ? void 0 : extra.presetStartTime) !== null && _extra$presetStartTim2 !== void 0 ? _extra$presetStartTim2 : derivePresetStartTimeFromDate(date),
|
|
1546
|
+
customerId: orderCustomerId
|
|
1547
|
+
}, extra || {});
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
1552
|
+
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
1553
|
+
*/
|
|
1554
|
+
}, {
|
|
1555
|
+
key: "decideAddProduct",
|
|
1556
|
+
value: function decideAddProduct(item, options) {
|
|
1557
|
+
return decideAddProductUtil(item, this.buildAddProductCtx(options));
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/** 规格弹窗 callback 后的第二段决策。 */
|
|
1561
|
+
}, {
|
|
1562
|
+
key: "decideAfterDetail",
|
|
1563
|
+
value: function decideAfterDetail(cacheItem, options) {
|
|
1564
|
+
return decideAfterDetailUtil(cacheItem, this.buildAddProductCtx(options));
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* @deprecated 请用 `decideAddProduct`;`autoClose=true` 仅当 action=add。
|
|
1569
|
+
*/
|
|
1570
|
+
}, {
|
|
1571
|
+
key: "decideAutoClose",
|
|
1572
|
+
value: function decideAutoClose(item, options) {
|
|
1573
|
+
return decideAutoCloseUtil(item, this.buildAddProductCtx(options));
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
/** 替代 info2 `getIsEject`:商品是否需要弹窗(0/1)。 */
|
|
1577
|
+
}, {
|
|
1578
|
+
key: "getIsEject",
|
|
1579
|
+
value: function getIsEject(item) {
|
|
1580
|
+
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'select';
|
|
1581
|
+
return getIsEjectUtil(item, type);
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
/** 仅 session 商品(无 variant/option/package)→ true。 */
|
|
1585
|
+
}, {
|
|
1586
|
+
key: "getIsOnlySession",
|
|
1587
|
+
value: function getIsOnlySession(item) {
|
|
1588
|
+
return getIsOnlySessionUtil(item);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
/**
|
|
1592
|
+
* 拼装 requiresDetail payload(给 SDK 直接 return 给 UI 用)。
|
|
1593
|
+
*/
|
|
1594
|
+
}, {
|
|
1595
|
+
key: "buildRequiresDetailPayload",
|
|
1596
|
+
value: function buildRequiresDetailPayload(item, options) {
|
|
1597
|
+
return _buildRequiresDetailPayload(item, this.buildAddProductCtx(options));
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
/**
|
|
1601
|
+
* 把 detail 弹窗回调结果(e, extension_type, detail)转换为 `(product, booking)` 入参。
|
|
1602
|
+
* 内部会先拼 cacheItem,再走 cacheItemToBookingInput 严格协议对齐。
|
|
1603
|
+
*/
|
|
1604
|
+
}, {
|
|
1605
|
+
key: "transformDetailToProductAndBooking",
|
|
1606
|
+
value: function transformDetailToProductAndBooking(input) {
|
|
1607
|
+
var item = input.item,
|
|
1608
|
+
preparedCacheItem = input.cacheItem,
|
|
1609
|
+
detailResult = input.detailResult,
|
|
1610
|
+
options = input.options;
|
|
1611
|
+
var ctx = this.buildAddProductCtx(options);
|
|
1612
|
+
var cacheItem = preparedCacheItem || (detailResult ? buildCacheItemFromDetail(item, detailResult, ctx) : buildCacheItemFromCartDetail(item, ctx));
|
|
1613
|
+
return transformDetailToProductAndBookingUtil(cacheItem, ctx);
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1616
|
+
/**
|
|
1617
|
+
* 从已加车的 order line + booking 反查资源编辑抽屉所需的 cacheItem。
|
|
1618
|
+
* 供 SalesSdk「编辑资源」等场景使用;字段语义与 buildCacheItemFromDetail 产出对齐。
|
|
1619
|
+
*/
|
|
1620
|
+
}, {
|
|
1621
|
+
key: "buildCacheItemFromOrderLine",
|
|
1622
|
+
value: function buildCacheItemFromOrderLine(input) {
|
|
1623
|
+
return buildCacheItemFromOrderLineUtil(input);
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* 从已加车的普通商品 order line 反查 SkuDetailModal edit 所需的 cacheItem。
|
|
1628
|
+
*/
|
|
1629
|
+
}, {
|
|
1630
|
+
key: "buildNormalProductCacheItemFromOrderLine",
|
|
1631
|
+
value: function buildNormalProductCacheItemFromOrderLine(input) {
|
|
1632
|
+
return buildNormalProductCacheItemFromOrderLineUtil(input);
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
|
|
1636
|
+
}, {
|
|
1637
|
+
key: "updateProductInOrder",
|
|
1638
|
+
value: (function () {
|
|
1639
|
+
var _updateProductInOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
1640
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1641
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1642
|
+
case 0:
|
|
1643
|
+
return _context21.abrupt("return", this.updateOrderProduct(params));
|
|
1644
|
+
case 1:
|
|
1645
|
+
case "end":
|
|
1646
|
+
return _context21.stop();
|
|
1647
|
+
}
|
|
1648
|
+
}, _callee21, this);
|
|
1649
|
+
}));
|
|
1650
|
+
function updateProductInOrder(_x15) {
|
|
1651
|
+
return _updateProductInOrder.apply(this, arguments);
|
|
1652
|
+
}
|
|
1653
|
+
return updateProductInOrder;
|
|
1053
1654
|
}()
|
|
1054
1655
|
/**
|
|
1055
1656
|
* 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
|
|
@@ -1059,12 +1660,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1059
1660
|
}, {
|
|
1060
1661
|
key: "destroy",
|
|
1061
1662
|
value: (function () {
|
|
1062
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1663
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1063
1664
|
var _this$scan;
|
|
1064
|
-
return _regeneratorRuntime().wrap(function
|
|
1065
|
-
while (1) switch (
|
|
1665
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1666
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1066
1667
|
case 0:
|
|
1067
|
-
|
|
1668
|
+
_context22.next = 2;
|
|
1068
1669
|
return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
|
|
1069
1670
|
case 2:
|
|
1070
1671
|
try {
|
|
@@ -1075,9 +1676,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1075
1676
|
scanCache.clear();
|
|
1076
1677
|
case 4:
|
|
1077
1678
|
case "end":
|
|
1078
|
-
return
|
|
1679
|
+
return _context22.stop();
|
|
1079
1680
|
}
|
|
1080
|
-
},
|
|
1681
|
+
}, _callee22, this);
|
|
1081
1682
|
}));
|
|
1082
1683
|
function destroy() {
|
|
1083
1684
|
return _destroy.apply(this, arguments);
|