@pisell/pisellos 2.3.229 → 2.3.231
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/adapter.js +14 -2
- package/dist/model/strategy/adapter/promotion/evaluator.js +23 -8
- package/dist/model/strategy/adapter/promotion/type.d.ts +10 -2
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +1371 -1234
- package/dist/modules/Order/types.d.ts +13 -34
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Summary/utils.d.ts +1 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
- package/dist/solution/BaseSales/utils/cartPromotion.js +252 -168
- package/dist/solution/BookingTicket/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.js +45 -21
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +10 -10
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +52 -38
- package/dist/solution/ScanOrder/menuAvailability.js +3 -25
- package/dist/solution/ScanOrder/shopTime.d.ts +6 -0
- package/dist/solution/ScanOrder/shopTime.js +36 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +10 -1
- package/lib/model/strategy/adapter/promotion/evaluator.js +18 -6
- package/lib/model/strategy/adapter/promotion/type.d.ts +10 -2
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +103 -32
- package/lib/modules/Order/types.d.ts +13 -34
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Summary/utils.d.ts +1 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +5 -18
- package/lib/solution/BaseSales/utils/cartPromotion.js +87 -40
- package/lib/solution/BookingTicket/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.js +28 -11
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +10 -10
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +26 -13
- package/lib/solution/ScanOrder/menuAvailability.js +3 -20
- package/lib/solution/ScanOrder/shopTime.d.ts +6 -0
- package/lib/solution/ScanOrder/shopTime.js +37 -0
- package/package.json +1 -1
|
@@ -295,7 +295,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
295
295
|
private getCustomerContactOrderKey;
|
|
296
296
|
replaceTempOrder(...args: Parameters<BaseSalesImpl['replaceTempOrder']>): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
297
297
|
private applyDefaultOrderCustomerContactInfo;
|
|
298
|
-
private
|
|
298
|
+
private withAccountContactFallback;
|
|
299
299
|
private prefillOrderCustomerContactInfo;
|
|
300
300
|
protected waitForOrderCustomerContactInfo(): Promise<void>;
|
|
301
301
|
validateContactInfo(): Promise<void>;
|
|
@@ -374,7 +374,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
374
374
|
* 获取当前的客户搜索条件
|
|
375
375
|
* @returns 当前搜索条件
|
|
376
376
|
*/
|
|
377
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
377
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
|
|
378
378
|
/**
|
|
379
379
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
380
380
|
* @returns 客户状态
|
|
@@ -2048,27 +2048,51 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2048
2048
|
return applyDefaultOrderCustomerContactInfo;
|
|
2049
2049
|
}()
|
|
2050
2050
|
}, {
|
|
2051
|
-
key: "
|
|
2052
|
-
value: function
|
|
2051
|
+
key: "withAccountContactFallback",
|
|
2052
|
+
value: function withAccountContactFallback(contact, customer) {
|
|
2053
2053
|
var next = contact;
|
|
2054
|
-
// Saved booking contacts take precedence.
|
|
2055
|
-
//
|
|
2056
|
-
var _iterator2 = _createForOfIteratorHelper(['first_name', 'last_name']),
|
|
2054
|
+
// Saved booking contacts take precedence. Fill only missing fields from the
|
|
2055
|
+
// account, without mutating its profile or replacing an existing contact number.
|
|
2056
|
+
var _iterator2 = _createForOfIteratorHelper(['first_name', 'last_name', 'email']),
|
|
2057
2057
|
_step2;
|
|
2058
2058
|
try {
|
|
2059
2059
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2060
|
-
var
|
|
2061
|
-
if (typeof (contact === null || contact === void 0 ? void 0 : contact[
|
|
2062
|
-
var
|
|
2063
|
-
if (typeof
|
|
2060
|
+
var _field = _step2.value;
|
|
2061
|
+
if (typeof (contact === null || contact === void 0 ? void 0 : contact[_field]) === 'string' && contact[_field].trim()) continue;
|
|
2062
|
+
var _value = customer[_field];
|
|
2063
|
+
if (typeof _value !== 'string' || !_value.trim()) continue;
|
|
2064
2064
|
if (next === contact) next = _objectSpread({}, contact);
|
|
2065
|
-
next[
|
|
2065
|
+
next[_field] = _value.trim();
|
|
2066
2066
|
}
|
|
2067
2067
|
} catch (err) {
|
|
2068
2068
|
_iterator2.e(err);
|
|
2069
2069
|
} finally {
|
|
2070
2070
|
_iterator2.f();
|
|
2071
2071
|
}
|
|
2072
|
+
var phone = isContactRecord(contact === null || contact === void 0 ? void 0 : contact.phone) ? contact.phone : null;
|
|
2073
|
+
if (!(typeof (phone === null || phone === void 0 ? void 0 : phone.phone) === 'string' && phone.phone.trim()) && typeof customer.phone === 'string' && customer.phone.trim()) {
|
|
2074
|
+
// The account number must travel with its own dialing code, not an empty
|
|
2075
|
+
// contact form's default country (for example AU for a +86 login number).
|
|
2076
|
+
var accountPhone = _objectSpread(_objectSpread({}, phone), {}, {
|
|
2077
|
+
phone: customer.phone.trim()
|
|
2078
|
+
});
|
|
2079
|
+
var _iterator3 = _createForOfIteratorHelper(['country_calling_code', 'country_code']),
|
|
2080
|
+
_step3;
|
|
2081
|
+
try {
|
|
2082
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2083
|
+
var field = _step3.value;
|
|
2084
|
+
var value = customer[field];
|
|
2085
|
+
accountPhone[field] = typeof value === 'string' || typeof value === 'number' ? String(value).trim() : '';
|
|
2086
|
+
}
|
|
2087
|
+
} catch (err) {
|
|
2088
|
+
_iterator3.e(err);
|
|
2089
|
+
} finally {
|
|
2090
|
+
_iterator3.f();
|
|
2091
|
+
}
|
|
2092
|
+
next = _objectSpread(_objectSpread({}, next), {}, {
|
|
2093
|
+
phone: accountPhone
|
|
2094
|
+
});
|
|
2095
|
+
}
|
|
2072
2096
|
return next;
|
|
2073
2097
|
}
|
|
2074
2098
|
}, {
|
|
@@ -2087,13 +2111,13 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2087
2111
|
var contact = (_order$contacts_info = order.contacts_info) !== null && _order$contacts_info !== void 0 ? _order$contacts_info : extractCustomerContactInfo(customer);
|
|
2088
2112
|
if (contact) {
|
|
2089
2113
|
this.orderCustomerContactRequest = null;
|
|
2090
|
-
var next = this.
|
|
2114
|
+
var next = this.withAccountContactFallback(contact, customer);
|
|
2091
2115
|
if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
|
|
2092
2116
|
return;
|
|
2093
2117
|
}
|
|
2094
2118
|
// A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
|
|
2095
2119
|
if (customer.contacts_info !== undefined) {
|
|
2096
|
-
var _next3 = this.
|
|
2120
|
+
var _next3 = this.withAccountContactFallback(null, customer);
|
|
2097
2121
|
if (_next3) void this.applyDefaultOrderCustomerContactInfo(_next3);
|
|
2098
2122
|
return;
|
|
2099
2123
|
}
|
|
@@ -2142,7 +2166,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2142
2166
|
return _this5.resolveCustomerById(customerId);
|
|
2143
2167
|
case 9:
|
|
2144
2168
|
resolved = _context30.sent;
|
|
2145
|
-
return _context30.abrupt("return", resolved && Number(resolved.id) === customerId ? _this5.
|
|
2169
|
+
return _context30.abrupt("return", resolved && Number(resolved.id) === customerId ? _this5.withAccountContactFallback(extractCustomerContactInfo(resolved), resolved) : null);
|
|
2146
2170
|
case 11:
|
|
2147
2171
|
case "end":
|
|
2148
2172
|
return _context30.stop();
|
|
@@ -2167,7 +2191,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2167
2191
|
}
|
|
2168
2192
|
return _context31.abrupt("return");
|
|
2169
2193
|
case 3:
|
|
2170
|
-
next = _this5.
|
|
2194
|
+
next = _this5.withAccountContactFallback(value, customer);
|
|
2171
2195
|
if (!next) {
|
|
2172
2196
|
_context31.next = 7;
|
|
2173
2197
|
break;
|
|
@@ -3547,7 +3571,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3547
3571
|
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(input) {
|
|
3548
3572
|
var _this13 = this,
|
|
3549
3573
|
_input$bookingPatch;
|
|
3550
|
-
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result,
|
|
3574
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator4, _step4, line;
|
|
3551
3575
|
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3552
3576
|
while (1) switch (_context46.prev = _context46.next) {
|
|
3553
3577
|
case 0:
|
|
@@ -3584,15 +3608,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3584
3608
|
return _context46.abrupt("return", this.store.order.addProductsToOrder(orderLines));
|
|
3585
3609
|
case 11:
|
|
3586
3610
|
result = [];
|
|
3587
|
-
|
|
3611
|
+
_iterator4 = _createForOfIteratorHelper(orderLines);
|
|
3588
3612
|
_context46.prev = 13;
|
|
3589
|
-
|
|
3613
|
+
_iterator4.s();
|
|
3590
3614
|
case 15:
|
|
3591
|
-
if ((
|
|
3615
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
3592
3616
|
_context46.next = 29;
|
|
3593
3617
|
break;
|
|
3594
3618
|
}
|
|
3595
|
-
line =
|
|
3619
|
+
line = _step4.value;
|
|
3596
3620
|
_context46.t0 = result.splice;
|
|
3597
3621
|
_context46.t1 = result;
|
|
3598
3622
|
_context46.t2 = [0, result.length];
|
|
@@ -3613,10 +3637,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3613
3637
|
case 31:
|
|
3614
3638
|
_context46.prev = 31;
|
|
3615
3639
|
_context46.t7 = _context46["catch"](13);
|
|
3616
|
-
|
|
3640
|
+
_iterator4.e(_context46.t7);
|
|
3617
3641
|
case 34:
|
|
3618
3642
|
_context46.prev = 34;
|
|
3619
|
-
|
|
3643
|
+
_iterator4.f();
|
|
3620
3644
|
return _context46.finish(34);
|
|
3621
3645
|
case 37:
|
|
3622
3646
|
return _context46.abrupt("return", result);
|
|
@@ -25,17 +25,25 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
27
|
small_ticket_data_flag?: number | undefined;
|
|
28
|
+
type: string;
|
|
28
29
|
metadata: Record<string, any>;
|
|
30
|
+
holder: Record<string, any> | null;
|
|
29
31
|
note: string;
|
|
32
|
+
status: string;
|
|
33
|
+
bookings: any[];
|
|
34
|
+
payments: any[];
|
|
35
|
+
contacts_info: Record<string, any> | null;
|
|
36
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
37
|
+
refunds?: any[] | undefined;
|
|
38
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
30
39
|
order_id: number | null;
|
|
40
|
+
external_sale_number: string;
|
|
31
41
|
order_number: string | null;
|
|
32
42
|
shop_order_number: string | null;
|
|
33
43
|
shop_full_order_number: string | null;
|
|
34
|
-
type: string;
|
|
35
44
|
business_code?: string | undefined;
|
|
36
45
|
sales_channel: string;
|
|
37
46
|
order_sales_channel: string;
|
|
38
|
-
status: string;
|
|
39
47
|
shipping_status: string;
|
|
40
48
|
customer_id: number | null;
|
|
41
49
|
customer_name: string;
|
|
@@ -56,17 +64,9 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
56
64
|
delivery_type?: string | undefined;
|
|
57
65
|
table_number?: Record<string, any> | undefined;
|
|
58
66
|
schedule_date: string;
|
|
59
|
-
bookings: any[];
|
|
60
|
-
payments: any[];
|
|
61
67
|
surcharges: any[];
|
|
62
68
|
relation_forms: any[];
|
|
63
69
|
contacts: any[];
|
|
64
|
-
contacts_info: Record<string, any> | null;
|
|
65
|
-
holder: Record<string, any> | null;
|
|
66
|
-
external_sale_number: string;
|
|
67
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
68
|
-
refunds?: any[] | undefined;
|
|
69
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
72
72
|
schedule_event_id: any;
|
|
@@ -98,6 +98,7 @@ export declare class ScanOrderImpl extends BaseSalesImpl implements Module {
|
|
|
98
98
|
private findReservationRuleResource;
|
|
99
99
|
private buildScanOrderResourceMetadata;
|
|
100
100
|
private prepareRetailAvailability;
|
|
101
|
+
private getShopTime;
|
|
101
102
|
private buildSubmitPayloadEnhancer;
|
|
102
103
|
private isScanOrderMoreMode;
|
|
103
104
|
private submitScanOrderMore;
|
|
@@ -37,7 +37,7 @@ import { createModule } from "../BookingByStep/types";
|
|
|
37
37
|
import { ProductList } from "../../modules/ProductList";
|
|
38
38
|
import { getDateIsInSchedule } from "../../modules/Schedule/getDateIsInSchedule";
|
|
39
39
|
import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOptions, normalizeSubmitBooking, normalizeSubmitCollectPaxValue, resolveTableOccupancyDuration, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
-
import
|
|
40
|
+
import { createScanOrderShopClock } from "./shopTime";
|
|
41
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
42
42
|
import { prepareScanOrderMenuAvailability, ScanOrderMenuAvailabilityError } from "./menuAvailability";
|
|
43
43
|
import { formatScanOrderMoreProducts } from "./additionalOrderPayload";
|
|
@@ -1333,7 +1333,16 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1333
1333
|
return _prepareRetailAvailability.apply(this, arguments);
|
|
1334
1334
|
}
|
|
1335
1335
|
return prepareRetailAvailability;
|
|
1336
|
-
}()
|
|
1336
|
+
}()
|
|
1337
|
+
}, {
|
|
1338
|
+
key: "getShopTime",
|
|
1339
|
+
value: function getShopTime() {
|
|
1340
|
+
var _this$getPickupTiming;
|
|
1341
|
+
var instant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
1342
|
+
return createScanOrderShopClock(String((_this$getPickupTiming = this.getPickupTimingContextData('timezone')) !== null && _this$getPickupTiming !== void 0 ? _this$getPickupTiming : ''))(instant);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
// ScanOrder 提交 payload enhancer:
|
|
1337
1346
|
// - 新单有桌台上下文但无 booking 时,补建基础预约(通用 Order 已不再自动生成)
|
|
1338
1347
|
// - 给所有 booking 注入 appointment_status: 'started'(扫码点餐语义)
|
|
1339
1348
|
// - 给所有 booking 的 metadata 注入 resource_select_type(来自预约规则商品的 resource.type)
|
|
@@ -1430,22 +1439,25 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1430
1439
|
var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
|
|
1431
1440
|
var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
|
|
1432
1441
|
var bookings = payload.bookings || [];
|
|
1442
|
+
var scheduleDate = payload.schedule_date;
|
|
1433
1443
|
if (!tempOrder.order_id && bookings.length === 0) {
|
|
1434
|
-
var bookingStart =
|
|
1444
|
+
var bookingStart = _this5.getShopTime(now);
|
|
1435
1445
|
var bookingDuration = resolveTableOccupancyDuration(tempOrder);
|
|
1436
|
-
|
|
1446
|
+
// Add elapsed minutes before formatting both ends so DST changes are respected.
|
|
1447
|
+
var bookingEnd = _this5.getShopTime(new Date(now.getTime() + bookingDuration * 60000));
|
|
1448
|
+
scheduleDate = bookingStart.dateTime;
|
|
1437
1449
|
bookings = [normalizeSubmitBooking({
|
|
1438
1450
|
relation_id: 0,
|
|
1439
1451
|
form_id: 0,
|
|
1440
|
-
start_time: bookingStart.
|
|
1441
|
-
start_date: bookingStart.
|
|
1442
|
-
end_time: bookingEnd.
|
|
1443
|
-
end_date: bookingEnd.
|
|
1452
|
+
start_time: bookingStart.time,
|
|
1453
|
+
start_date: bookingStart.date,
|
|
1454
|
+
end_time: bookingEnd.time,
|
|
1455
|
+
end_date: bookingEnd.date,
|
|
1444
1456
|
duration: bookingDuration,
|
|
1445
1457
|
metadata: {
|
|
1446
1458
|
unique_identification_number: bookingUuid
|
|
1447
1459
|
},
|
|
1448
|
-
select_date: bookingStart.
|
|
1460
|
+
select_date: bookingStart.date,
|
|
1449
1461
|
is_all: false,
|
|
1450
1462
|
like_status: 'common',
|
|
1451
1463
|
schedule_id: 0,
|
|
@@ -1506,6 +1518,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1506
1518
|
});
|
|
1507
1519
|
}
|
|
1508
1520
|
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
1521
|
+
schedule_date: scheduleDate,
|
|
1509
1522
|
bookings: nextBookings,
|
|
1510
1523
|
products: nextProducts
|
|
1511
1524
|
});
|
|
@@ -1629,7 +1642,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1629
1642
|
value: function () {
|
|
1630
1643
|
var _submitScanOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1631
1644
|
var _this6 = this;
|
|
1632
|
-
var _this$store$resource2, _resource$relationId, _this$otherParams13, _this$
|
|
1645
|
+
var _this$store$resource2, _resource$relationId, _this$otherParams13, _this$getPickupTiming2, _tempOrder$products, pax, tempOrderForSubmit, resourceTableName, isAdditionalOrder, enhanceBookingPayload, ruleProduct, resource, willAppendRuleProduct, productsToPrepare, associatedMenus, validateMenuAvailability, enhancePayload, result, tempOrder;
|
|
1633
1646
|
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1634
1647
|
while (1) switch (_context18.prev = _context18.next) {
|
|
1635
1648
|
case 0:
|
|
@@ -1685,7 +1698,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1685
1698
|
menuIds: associatedMenus.map(function (menu) {
|
|
1686
1699
|
return menu === null || menu === void 0 ? void 0 : menu.value;
|
|
1687
1700
|
}),
|
|
1688
|
-
timezone: String((_this$
|
|
1701
|
+
timezone: String((_this$getPickupTiming2 = this.getPickupTimingContextData('timezone')) !== null && _this$getPickupTiming2 !== void 0 ? _this$getPickupTiming2 : ''),
|
|
1689
1702
|
products: productsToPrepare,
|
|
1690
1703
|
productSources: this.getMenuAvailabilityProductSources(tempOrderForSubmit)
|
|
1691
1704
|
});
|
|
@@ -2906,6 +2919,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2906
2919
|
pendingRequestPaxMin,
|
|
2907
2920
|
pendingRequestPaxMax,
|
|
2908
2921
|
reservationProductList,
|
|
2922
|
+
_this$getShopTime,
|
|
2909
2923
|
scheduleDate,
|
|
2910
2924
|
scheduleDatetime,
|
|
2911
2925
|
loaded,
|
|
@@ -3004,7 +3018,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3004
3018
|
if (operatingHourIds.length && this.store.schedule) {
|
|
3005
3019
|
scheduleList = this.store.schedule.getScheduleListByIds(operatingHourIds);
|
|
3006
3020
|
if (scheduleList.length) {
|
|
3007
|
-
now =
|
|
3021
|
+
now = this.getShopTime().dateTime;
|
|
3008
3022
|
outsideOperatingHours = !getDateIsInSchedule(now, scheduleList);
|
|
3009
3023
|
}
|
|
3010
3024
|
}
|
|
@@ -3048,16 +3062,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3048
3062
|
})
|
|
3049
3063
|
});
|
|
3050
3064
|
case 42:
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
_context37.next = 46;
|
|
3065
|
+
_this$getShopTime = this.getShopTime(), scheduleDate = _this$getShopTime.date, scheduleDatetime = _this$getShopTime.dateTime;
|
|
3066
|
+
_context37.next = 45;
|
|
3054
3067
|
return reservationProductList.loadProducts({
|
|
3055
3068
|
product_ids: reservationLinkIds,
|
|
3056
3069
|
schedule_date: scheduleDate,
|
|
3057
3070
|
schedule_datetime: scheduleDatetime,
|
|
3058
3071
|
cacheId: this.cacheId
|
|
3059
3072
|
});
|
|
3060
|
-
case
|
|
3073
|
+
case 45:
|
|
3061
3074
|
loaded = _context37.sent;
|
|
3062
3075
|
if (Array.isArray(loaded)) {
|
|
3063
3076
|
matchedRuleProduct = findReservationRuleProductByResourceId(loaded, normalizedResourceId);
|
|
@@ -3109,9 +3122,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3109
3122
|
}
|
|
3110
3123
|
|
|
3111
3124
|
// Step2: 请求新的资源占用详情接口。occupy_details 第一维是资源,不是订单。
|
|
3112
|
-
_context37.next =
|
|
3125
|
+
_context37.next = 49;
|
|
3113
3126
|
return this.fetchResourceOccupyDetailsByResourceId(normalizedResourceId);
|
|
3114
|
-
case
|
|
3127
|
+
case 49:
|
|
3115
3128
|
occupyDetails = _context37.sent;
|
|
3116
3129
|
occupyDetail = (_occupyDetails$ = occupyDetails[0]) !== null && _occupyDetails$ !== void 0 ? _occupyDetails$ : null; // Step3: 结合预约规则商品的 product_resource.resources 与占用接口返回的 form_id,
|
|
3117
3130
|
// 计算当前桌台的 resourceSelectType(single/multiple/capacity)
|
|
@@ -3119,7 +3132,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3119
3132
|
allowAddItems = toBoolean(dineInConfig === null || dineInConfig === void 0 ? void 0 : dineInConfig['sale.allow_add_items']);
|
|
3120
3133
|
additionalOrderResult = this.resolveAdditionalOrderFromOccupyDetail(occupyDetail, resourceSelectType, allowAddItems);
|
|
3121
3134
|
if (!(additionalOrderResult.reason === 'multiple_orders')) {
|
|
3122
|
-
_context37.next =
|
|
3135
|
+
_context37.next = 60;
|
|
3123
3136
|
break;
|
|
3124
3137
|
}
|
|
3125
3138
|
multipleOrdersState = _objectSpread(_objectSpread({}, this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId)), {}, {
|
|
@@ -3140,7 +3153,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3140
3153
|
resourceSelectType: resourceSelectType
|
|
3141
3154
|
});
|
|
3142
3155
|
return _context37.abrupt("return", _availabilityInfo);
|
|
3143
|
-
case
|
|
3156
|
+
case 60:
|
|
3144
3157
|
// Step4: 用 occupyDetail + resourceSelectType 规整为 resourceState
|
|
3145
3158
|
resourceState = this.normalizeResourceState(occupyDetail, resourceSelectType, hasOrderId);
|
|
3146
3159
|
additionalOrderId = additionalOrderResult.order_id;
|
|
@@ -3186,12 +3199,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3186
3199
|
|
|
3187
3200
|
// 空闲状态下自动准备本地临时订单,供后续“购物车式”商品操作使用
|
|
3188
3201
|
if (!(availabilityInfo.mode === 'idle')) {
|
|
3189
|
-
_context37.next =
|
|
3202
|
+
_context37.next = 72;
|
|
3190
3203
|
break;
|
|
3191
3204
|
}
|
|
3192
|
-
_context37.next =
|
|
3205
|
+
_context37.next = 72;
|
|
3193
3206
|
return this.addNewOrder();
|
|
3194
|
-
case
|
|
3207
|
+
case 72:
|
|
3195
3208
|
isAdditionalOrderMode = availabilityInfo.mode === 'additional_order' || availabilityInfo.mode === 'additional_order_with_code'; // 如果是加单模式,tempOrder 里需要记录目标订单 id,提交的时候走加单接口
|
|
3196
3209
|
if (isAdditionalOrderMode) {
|
|
3197
3210
|
tempOrder.order_id = additionalOrderId;
|
|
@@ -3207,13 +3220,13 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3207
3220
|
} : {}));
|
|
3208
3221
|
return acc;
|
|
3209
3222
|
}, []) : []; // pax 由 setEntryPaxNumber 负责写入 itemRuleRuntimeConfig.pax
|
|
3210
|
-
_context37.next =
|
|
3223
|
+
_context37.next = 78;
|
|
3211
3224
|
return this.setItemRuleRuntimeConfig({
|
|
3212
3225
|
serviceType: (_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode,
|
|
3213
3226
|
submissionIndex: isAdditionalOrderMode ? 1 : 0,
|
|
3214
3227
|
historicalItems: historicalItems
|
|
3215
3228
|
});
|
|
3216
|
-
case
|
|
3229
|
+
case 78:
|
|
3217
3230
|
// operating_hours 超出营业时段 + closed_behavior=show_menu_disabled:
|
|
3218
3231
|
// 允许浏览商品但 UI 层需拦截“下一步”,这里覆盖最终 mode 并回传错误提示
|
|
3219
3232
|
if (outsideOperatingHours && closedBehaviorValue === 'show_menu_disabled') {
|
|
@@ -3235,18 +3248,18 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3235
3248
|
isFull: resourceState.isFull
|
|
3236
3249
|
});
|
|
3237
3250
|
return _context37.abrupt("return", availabilityInfo);
|
|
3238
|
-
case
|
|
3239
|
-
_context37.prev =
|
|
3251
|
+
case 83:
|
|
3252
|
+
_context37.prev = 83;
|
|
3240
3253
|
_context37.t0 = _context37["catch"](3);
|
|
3241
3254
|
this.logMethodError('checkResourceAvailable', _context37.t0.message, {
|
|
3242
3255
|
resourceId: normalizedResourceId
|
|
3243
3256
|
});
|
|
3244
3257
|
throw _context37.t0;
|
|
3245
|
-
case
|
|
3258
|
+
case 87:
|
|
3246
3259
|
case "end":
|
|
3247
3260
|
return _context37.stop();
|
|
3248
3261
|
}
|
|
3249
|
-
}, _callee37, this, [[3,
|
|
3262
|
+
}, _callee37, this, [[3, 83]]);
|
|
3250
3263
|
}));
|
|
3251
3264
|
function checkResourceAvailable(_x20) {
|
|
3252
3265
|
return _checkResourceAvailable.apply(this, arguments);
|
|
@@ -3336,7 +3349,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3336
3349
|
value: function () {
|
|
3337
3350
|
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3338
3351
|
var _this$otherParams21;
|
|
3339
|
-
var associatedMenus, menu_list_ids, res, productList, formattedRes;
|
|
3352
|
+
var associatedMenus, menu_list_ids, _this$getShopTime2, date, dateTime, res, productList, formattedRes;
|
|
3340
3353
|
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3341
3354
|
while (1) switch (_context40.prev = _context40.next) {
|
|
3342
3355
|
case 0:
|
|
@@ -3353,14 +3366,15 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3353
3366
|
}
|
|
3354
3367
|
throw new Error('products 模块未初始化');
|
|
3355
3368
|
case 6:
|
|
3356
|
-
|
|
3369
|
+
_this$getShopTime2 = this.getShopTime(), date = _this$getShopTime2.date, dateTime = _this$getShopTime2.dateTime;
|
|
3370
|
+
_context40.next = 9;
|
|
3357
3371
|
return this.store.products.loadProducts({
|
|
3358
3372
|
menu_list_ids: menu_list_ids,
|
|
3359
3373
|
cacheId: this.cacheId,
|
|
3360
|
-
schedule_date:
|
|
3361
|
-
schedule_datetime:
|
|
3374
|
+
schedule_date: date,
|
|
3375
|
+
schedule_datetime: dateTime
|
|
3362
3376
|
});
|
|
3363
|
-
case
|
|
3377
|
+
case 9:
|
|
3364
3378
|
res = _context40.sent;
|
|
3365
3379
|
productList = this.assertProductListLoaded('getProductList', res, {
|
|
3366
3380
|
menu_list_ids: menu_list_ids,
|
|
@@ -3371,8 +3385,8 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3371
3385
|
menuCount: menu_list_ids.length
|
|
3372
3386
|
});
|
|
3373
3387
|
return _context40.abrupt("return", formattedRes);
|
|
3374
|
-
case
|
|
3375
|
-
_context40.prev =
|
|
3388
|
+
case 16:
|
|
3389
|
+
_context40.prev = 16;
|
|
3376
3390
|
_context40.t0 = _context40["catch"](3);
|
|
3377
3391
|
if (!(_context40.t0 !== null && _context40.t0 !== void 0 && _context40.t0.__scanOrderLogged)) {
|
|
3378
3392
|
this.logMethodError('getProductList', _context40.t0, {
|
|
@@ -3381,11 +3395,11 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3381
3395
|
});
|
|
3382
3396
|
}
|
|
3383
3397
|
throw _context40.t0;
|
|
3384
|
-
case
|
|
3398
|
+
case 20:
|
|
3385
3399
|
case "end":
|
|
3386
3400
|
return _context40.stop();
|
|
3387
3401
|
}
|
|
3388
|
-
}, _callee40, this, [[3,
|
|
3402
|
+
}, _callee40, this, [[3, 16]]);
|
|
3389
3403
|
}));
|
|
3390
3404
|
function getProductList() {
|
|
3391
3405
|
return _getProductList.apply(this, arguments);
|
|
@@ -31,6 +31,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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 { getDateIsInSchedule } from "../ShopDiscount/utils";
|
|
33
33
|
import dayjs from 'dayjs';
|
|
34
|
+
import { createScanOrderShopClock } from "./shopTime";
|
|
34
35
|
export var ScanOrderMenuAvailabilityError = /*#__PURE__*/function (_Error) {
|
|
35
36
|
_inherits(ScanOrderMenuAvailabilityError, _Error);
|
|
36
37
|
var _super = _createSuper(ScanOrderMenuAvailabilityError);
|
|
@@ -139,29 +140,6 @@ function validateSchedule(schedule) {
|
|
|
139
140
|
return typeof day !== 'number' || !Number.isInteger(day) || day < 0 || day > 6;
|
|
140
141
|
}))) return fail();
|
|
141
142
|
}
|
|
142
|
-
function createShopClock(timezone) {
|
|
143
|
-
if (typeof timezone !== 'string' || !timezone.trim()) return fail();
|
|
144
|
-
var formatter = new Intl.DateTimeFormat('en-GB', {
|
|
145
|
-
timeZone: timezone.trim(),
|
|
146
|
-
year: 'numeric',
|
|
147
|
-
month: '2-digit',
|
|
148
|
-
day: '2-digit',
|
|
149
|
-
hour: '2-digit',
|
|
150
|
-
minute: '2-digit',
|
|
151
|
-
second: '2-digit',
|
|
152
|
-
hourCycle: 'h23'
|
|
153
|
-
});
|
|
154
|
-
return function () {
|
|
155
|
-
var parts = formatter.formatToParts(new Date());
|
|
156
|
-
var value = function value(type) {
|
|
157
|
-
var _parts$find;
|
|
158
|
-
return (_parts$find = parts.find(function (part) {
|
|
159
|
-
return part.type === type;
|
|
160
|
-
})) === null || _parts$find === void 0 ? void 0 : _parts$find.value;
|
|
161
|
-
};
|
|
162
|
-
return "".concat(value('year'), "-").concat(value('month'), "-").concat(value('day'), " ").concat(value('hour'), ":").concat(value('minute'), ":").concat(value('second'));
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
143
|
function collectSources(target, sources) {
|
|
166
144
|
var _iterator = _createForOfIteratorHelper(sources),
|
|
167
145
|
_step;
|
|
@@ -206,7 +184,7 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
206
184
|
return id !== undefined;
|
|
207
185
|
});
|
|
208
186
|
_context.prev = 2;
|
|
209
|
-
now =
|
|
187
|
+
now = createScanOrderShopClock(timezone);
|
|
210
188
|
configuredIds = readIds(menuIds);
|
|
211
189
|
_context.next = 7;
|
|
212
190
|
return Promise.all([request.get('/form/data/v1', {
|
|
@@ -290,7 +268,7 @@ function _prepareScanOrderMenuAvailability() {
|
|
|
290
268
|
return _context.abrupt("return", function (currentProducts) {
|
|
291
269
|
var currentSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
292
270
|
try {
|
|
293
|
-
var currentTime = now();
|
|
271
|
+
var currentTime = now().dateTime;
|
|
294
272
|
var collections = new Map(collectionsByProduct);
|
|
295
273
|
collectSources(collections, [].concat(_toConsumableArray(currentProducts), _toConsumableArray(currentSources)));
|
|
296
274
|
var unavailable = [];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Format absolute instants as the shop's calendar fields, independent of the device timezone. */
|
|
2
|
+
export function createScanOrderShopClock(timezone) {
|
|
3
|
+
var message = 'Unable to determine store time. Please refresh and try again.';
|
|
4
|
+
var formatter;
|
|
5
|
+
try {
|
|
6
|
+
if (typeof timezone !== 'string' || !timezone.trim()) throw new Error(message);
|
|
7
|
+
formatter = new Intl.DateTimeFormat('en-GB', {
|
|
8
|
+
timeZone: timezone.trim(),
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
month: '2-digit',
|
|
11
|
+
day: '2-digit',
|
|
12
|
+
hour: '2-digit',
|
|
13
|
+
minute: '2-digit',
|
|
14
|
+
second: '2-digit',
|
|
15
|
+
hourCycle: 'h23'
|
|
16
|
+
});
|
|
17
|
+
} catch (_unused) {
|
|
18
|
+
throw new Error(message);
|
|
19
|
+
}
|
|
20
|
+
return function () {
|
|
21
|
+
var instant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
|
|
22
|
+
var parts = formatter.formatToParts(instant);
|
|
23
|
+
var value = function value(type) {
|
|
24
|
+
return parts.find(function (part) {
|
|
25
|
+
return part.type === type;
|
|
26
|
+
}).value;
|
|
27
|
+
};
|
|
28
|
+
var date = "".concat(value('year'), "-").concat(value('month'), "-").concat(value('day'));
|
|
29
|
+
var time = "".concat(value('hour'), ":").concat(value('minute'));
|
|
30
|
+
return {
|
|
31
|
+
date: date,
|
|
32
|
+
time: time,
|
|
33
|
+
dateTime: "".concat(date, " ").concat(time, ":").concat(value('second'))
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -174,13 +174,22 @@ class PromotionAdapter {
|
|
|
174
174
|
parseBuyXGetYFreeAction(action) {
|
|
175
175
|
const value = action.value || {};
|
|
176
176
|
const config = action.config || {};
|
|
177
|
+
const fixedGiftProducts = config.fixedGiftProducts;
|
|
178
|
+
if (fixedGiftProducts !== undefined) {
|
|
179
|
+
if (!Number.isSafeInteger(value.buyQuantity) || value.buyQuantity <= 0 || !Array.isArray(fixedGiftProducts) || fixedGiftProducts.length === 0 || fixedGiftProducts.some(gift => !gift || !Number.isSafeInteger(gift.product_id) || gift.product_id <= 0 || !Number.isSafeInteger(gift.product_variant_id) || gift.product_variant_id < 0 || !Number.isSafeInteger(gift.quantity) || gift.quantity <= 0) || new Set(fixedGiftProducts.map(gift => gift.product_id)).size !== fixedGiftProducts.length) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
177
183
|
return {
|
|
178
184
|
type: _type.PROMOTION_ACTION_TYPES.BUY_X_GET_Y_FREE,
|
|
179
185
|
buyQuantity: value.buyQuantity || 1,
|
|
180
186
|
freeQuantity: value.freeQuantity || 1,
|
|
181
187
|
giftSelectionMode: config.giftSelectionMode || 'user_select',
|
|
182
188
|
cumulative: config.cumulative ?? true,
|
|
183
|
-
giftProducts: config.giftProducts || []
|
|
189
|
+
giftProducts: config.giftProducts || [],
|
|
190
|
+
...(fixedGiftProducts && {
|
|
191
|
+
fixedGiftProducts
|
|
192
|
+
})
|
|
184
193
|
};
|
|
185
194
|
}
|
|
186
195
|
|
|
@@ -830,7 +830,8 @@ class PromotionEvaluator {
|
|
|
830
830
|
buyQuantity,
|
|
831
831
|
freeQuantity,
|
|
832
832
|
cumulative,
|
|
833
|
-
giftProducts
|
|
833
|
+
giftProducts,
|
|
834
|
+
fixedGiftProducts
|
|
834
835
|
} = detail;
|
|
835
836
|
const result = [];
|
|
836
837
|
let originalAmount = new _decimal.default(0);
|
|
@@ -896,17 +897,28 @@ class PromotionEvaluator {
|
|
|
896
897
|
}
|
|
897
898
|
|
|
898
899
|
// 4. 计算赠品数量(使用促销数量)
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
900
|
+
const groupCount = isFulfilled ? cumulative ? Math.floor(totalPromoQty / buyQuantity) : 1 : 0;
|
|
901
|
+
const giftQuotas = fixedGiftProducts?.map(gift => ({
|
|
902
|
+
...gift,
|
|
903
|
+
quantity: gift.quantity * groupCount
|
|
904
|
+
}));
|
|
905
|
+
const giftCount = giftQuotas ? giftQuotas.reduce((total, gift) => total + gift.quantity, 0) : groupCount * freeQuantity;
|
|
903
906
|
|
|
904
907
|
// 5. 构建赠品信息
|
|
905
908
|
const giftInfo = giftCount > 0 ? {
|
|
906
909
|
strategyId,
|
|
907
910
|
strategyName,
|
|
908
911
|
giftCount,
|
|
909
|
-
giftOptions:
|
|
912
|
+
giftOptions: fixedGiftProducts ? fixedGiftProducts.map(({
|
|
913
|
+
product_id,
|
|
914
|
+
product_variant_id
|
|
915
|
+
}) => ({
|
|
916
|
+
product_id,
|
|
917
|
+
product_variant_id
|
|
918
|
+
})) : giftProducts || [],
|
|
919
|
+
...(giftQuotas && {
|
|
920
|
+
giftQuotas
|
|
921
|
+
})
|
|
910
922
|
} : null;
|
|
911
923
|
return {
|
|
912
924
|
products: result,
|