@pisell/pisellos 2.3.227 → 2.3.229
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +2 -1
- package/dist/solution/BookingTicket/index.js +49 -18
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/dist/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
- package/dist/solution/ScanOrder/additionalOrderPayload.js +52 -0
- package/dist/solution/ScanOrder/index.js +11 -9
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +2 -1
- package/lib/solution/BookingTicket/index.js +27 -6
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/lib/solution/ScanOrder/additionalOrderPayload.d.ts +40 -0
- package/lib/solution/ScanOrder/additionalOrderPayload.js +50 -0
- package/lib/solution/ScanOrder/index.js +5 -3
- package/package.json +1 -1
|
@@ -644,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
644
644
|
generateIdempotencyToken(): string;
|
|
645
645
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
646
646
|
createOrder(params: CommitOrderParams['query']): {
|
|
647
|
-
type: "
|
|
647
|
+
type: "appointment_booking" | "virtual";
|
|
648
648
|
platform: string;
|
|
649
649
|
sales_channel: string;
|
|
650
650
|
order_sales_channel: string;
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 1 | 2 |
|
|
345
|
+
weekNum: 0 | 1 | 2 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -295,6 +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 withAccountNameFallback;
|
|
298
299
|
private prefillOrderCustomerContactInfo;
|
|
299
300
|
protected waitForOrderCustomerContactInfo(): Promise<void>;
|
|
300
301
|
validateContactInfo(): Promise<void>;
|
|
@@ -373,7 +374,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
373
374
|
* 获取当前的客户搜索条件
|
|
374
375
|
* @returns 当前搜索条件
|
|
375
376
|
*/
|
|
376
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
377
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
377
378
|
/**
|
|
378
379
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
379
380
|
* @returns 客户状态
|
|
@@ -2047,26 +2047,56 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2047
2047
|
}
|
|
2048
2048
|
return applyDefaultOrderCustomerContactInfo;
|
|
2049
2049
|
}()
|
|
2050
|
+
}, {
|
|
2051
|
+
key: "withAccountNameFallback",
|
|
2052
|
+
value: function withAccountNameFallback(contact, customer) {
|
|
2053
|
+
var next = contact;
|
|
2054
|
+
// Saved booking contacts take precedence. Only missing name fields fall back
|
|
2055
|
+
// to the account profile; phone/email keep their existing contact-info source.
|
|
2056
|
+
var _iterator2 = _createForOfIteratorHelper(['first_name', 'last_name']),
|
|
2057
|
+
_step2;
|
|
2058
|
+
try {
|
|
2059
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
2060
|
+
var field = _step2.value;
|
|
2061
|
+
if (typeof (contact === null || contact === void 0 ? void 0 : contact[field]) === 'string' && contact[field].trim()) continue;
|
|
2062
|
+
var name = customer[field];
|
|
2063
|
+
if (typeof name !== 'string' || !name.trim()) continue;
|
|
2064
|
+
if (next === contact) next = _objectSpread({}, contact);
|
|
2065
|
+
next[field] = name.trim();
|
|
2066
|
+
}
|
|
2067
|
+
} catch (err) {
|
|
2068
|
+
_iterator2.e(err);
|
|
2069
|
+
} finally {
|
|
2070
|
+
_iterator2.f();
|
|
2071
|
+
}
|
|
2072
|
+
return next;
|
|
2073
|
+
}
|
|
2050
2074
|
}, {
|
|
2051
2075
|
key: "prefillOrderCustomerContactInfo",
|
|
2052
2076
|
value: function prefillOrderCustomerContactInfo(customer, customerChanged) {
|
|
2053
2077
|
var _order$_extend2,
|
|
2078
|
+
_order$contacts_info,
|
|
2054
2079
|
_this$otherParams9,
|
|
2055
2080
|
_this5 = this;
|
|
2056
2081
|
var order = this.getTempOrder();
|
|
2057
2082
|
var customerId = Number(order === null || order === void 0 ? void 0 : order.customer_id);
|
|
2058
|
-
if (!order || !Number.isInteger(customerId) || customerId <= 1 ||
|
|
2083
|
+
if (!order || !Number.isInteger(customerId) || customerId <= 1 || (_order$_extend2 = order._extend) !== null && _order$_extend2 !== void 0 && _order$_extend2.contactInfoEdited) return;
|
|
2059
2084
|
// A restored new cart may already have its customer ID. Existing sales keep their snapshot,
|
|
2060
2085
|
// even when it is empty; only an explicit customer switch replaces it.
|
|
2061
2086
|
if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
|
|
2062
|
-
var contact = extractCustomerContactInfo(customer);
|
|
2087
|
+
var contact = (_order$contacts_info = order.contacts_info) !== null && _order$contacts_info !== void 0 ? _order$contacts_info : extractCustomerContactInfo(customer);
|
|
2063
2088
|
if (contact) {
|
|
2064
2089
|
this.orderCustomerContactRequest = null;
|
|
2065
|
-
|
|
2090
|
+
var next = this.withAccountNameFallback(contact, customer);
|
|
2091
|
+
if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
|
|
2066
2092
|
return;
|
|
2067
2093
|
}
|
|
2068
2094
|
// A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
|
|
2069
|
-
if (customer.contacts_info !== undefined)
|
|
2095
|
+
if (customer.contacts_info !== undefined) {
|
|
2096
|
+
var _next3 = this.withAccountNameFallback(null, customer);
|
|
2097
|
+
if (_next3) void this.applyDefaultOrderCustomerContactInfo(_next3);
|
|
2098
|
+
return;
|
|
2099
|
+
}
|
|
2070
2100
|
var userPlatform = isCustomerUserPlatform((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.platform);
|
|
2071
2101
|
var getAuthenticatedCustomerId = function getAuthenticatedCustomerId() {
|
|
2072
2102
|
var _this5$core, _this5$core$getPlugin, _this5$core$getPlugin2;
|
|
@@ -2112,7 +2142,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2112
2142
|
return _this5.resolveCustomerById(customerId);
|
|
2113
2143
|
case 9:
|
|
2114
2144
|
resolved = _context30.sent;
|
|
2115
|
-
return _context30.abrupt("return",
|
|
2145
|
+
return _context30.abrupt("return", resolved && Number(resolved.id) === customerId ? _this5.withAccountNameFallback(extractCustomerContactInfo(resolved), resolved) : null);
|
|
2116
2146
|
case 11:
|
|
2117
2147
|
case "end":
|
|
2118
2148
|
return _context30.stop();
|
|
@@ -2126,7 +2156,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2126
2156
|
pending.promise = loadContact().then( /*#__PURE__*/function () {
|
|
2127
2157
|
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(value) {
|
|
2128
2158
|
var _current$_extend;
|
|
2129
|
-
var current;
|
|
2159
|
+
var current, next;
|
|
2130
2160
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2131
2161
|
while (1) switch (_context31.prev = _context31.next) {
|
|
2132
2162
|
case 0:
|
|
@@ -2137,13 +2167,14 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
2137
2167
|
}
|
|
2138
2168
|
return _context31.abrupt("return");
|
|
2139
2169
|
case 3:
|
|
2140
|
-
|
|
2141
|
-
|
|
2170
|
+
next = _this5.withAccountNameFallback(value, customer);
|
|
2171
|
+
if (!next) {
|
|
2172
|
+
_context31.next = 7;
|
|
2142
2173
|
break;
|
|
2143
2174
|
}
|
|
2144
|
-
_context31.next =
|
|
2145
|
-
return _this5.applyDefaultOrderCustomerContactInfo(
|
|
2146
|
-
case
|
|
2175
|
+
_context31.next = 7;
|
|
2176
|
+
return _this5.applyDefaultOrderCustomerContactInfo(next);
|
|
2177
|
+
case 7:
|
|
2147
2178
|
case "end":
|
|
2148
2179
|
return _context31.stop();
|
|
2149
2180
|
}
|
|
@@ -3516,7 +3547,7 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3516
3547
|
var _addAddTimeProductsToBooking = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(input) {
|
|
3517
3548
|
var _this13 = this,
|
|
3518
3549
|
_input$bookingPatch;
|
|
3519
|
-
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result,
|
|
3550
|
+
var bookingUid, orderLines, coveredMinutes, bookingTimePatch, result, _iterator3, _step3, line;
|
|
3520
3551
|
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3521
3552
|
while (1) switch (_context46.prev = _context46.next) {
|
|
3522
3553
|
case 0:
|
|
@@ -3553,15 +3584,15 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3553
3584
|
return _context46.abrupt("return", this.store.order.addProductsToOrder(orderLines));
|
|
3554
3585
|
case 11:
|
|
3555
3586
|
result = [];
|
|
3556
|
-
|
|
3587
|
+
_iterator3 = _createForOfIteratorHelper(orderLines);
|
|
3557
3588
|
_context46.prev = 13;
|
|
3558
|
-
|
|
3589
|
+
_iterator3.s();
|
|
3559
3590
|
case 15:
|
|
3560
|
-
if ((
|
|
3591
|
+
if ((_step3 = _iterator3.n()).done) {
|
|
3561
3592
|
_context46.next = 29;
|
|
3562
3593
|
break;
|
|
3563
3594
|
}
|
|
3564
|
-
line =
|
|
3595
|
+
line = _step3.value;
|
|
3565
3596
|
_context46.t0 = result.splice;
|
|
3566
3597
|
_context46.t1 = result;
|
|
3567
3598
|
_context46.t2 = [0, result.length];
|
|
@@ -3582,10 +3613,10 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
3582
3613
|
case 31:
|
|
3583
3614
|
_context46.prev = 31;
|
|
3584
3615
|
_context46.t7 = _context46["catch"](13);
|
|
3585
|
-
|
|
3616
|
+
_iterator3.e(_context46.t7);
|
|
3586
3617
|
case 34:
|
|
3587
3618
|
_context46.prev = 34;
|
|
3588
|
-
|
|
3619
|
+
_iterator3.f();
|
|
3589
3620
|
return _context46.finish(34);
|
|
3590
3621
|
case 37:
|
|
3591
3622
|
return _context46.abrupt("return", result);
|
|
@@ -25,27 +25,19 @@ 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;
|
|
29
28
|
metadata: Record<string, any>;
|
|
30
|
-
business_code?: string | undefined;
|
|
31
|
-
status: string;
|
|
32
29
|
note: string;
|
|
33
|
-
holder: Record<string, any> | null;
|
|
34
|
-
customer_id: number | null;
|
|
35
|
-
bookings: any[];
|
|
36
|
-
payments: any[];
|
|
37
|
-
contacts_info: Record<string, any> | null;
|
|
38
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
39
|
-
refunds?: any[] | undefined;
|
|
40
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
41
30
|
order_id: number | null;
|
|
42
|
-
external_sale_number: string;
|
|
43
31
|
order_number: string | null;
|
|
44
32
|
shop_order_number: string | null;
|
|
45
33
|
shop_full_order_number: string | null;
|
|
34
|
+
type: string;
|
|
35
|
+
business_code?: string | undefined;
|
|
46
36
|
sales_channel: string;
|
|
47
37
|
order_sales_channel: string;
|
|
38
|
+
status: string;
|
|
48
39
|
shipping_status: string;
|
|
40
|
+
customer_id: number | null;
|
|
49
41
|
customer_name: string;
|
|
50
42
|
country_calling_code: string;
|
|
51
43
|
phone: string;
|
|
@@ -64,9 +56,17 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
64
56
|
delivery_type?: string | undefined;
|
|
65
57
|
table_number?: Record<string, any> | undefined;
|
|
66
58
|
schedule_date: string;
|
|
59
|
+
bookings: any[];
|
|
60
|
+
payments: any[];
|
|
67
61
|
surcharges: any[];
|
|
68
62
|
relation_forms: any[];
|
|
69
63
|
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;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OrderSubmitProduct } from '../../modules/Order/types';
|
|
2
|
+
interface ScanOrderMoreOption {
|
|
3
|
+
product_option_item_id: number;
|
|
4
|
+
option_group_id: number;
|
|
5
|
+
num: number;
|
|
6
|
+
price: string | number;
|
|
7
|
+
}
|
|
8
|
+
interface ScanOrderMoreBundle {
|
|
9
|
+
id: number;
|
|
10
|
+
group_id: number;
|
|
11
|
+
bundle_product_id: number;
|
|
12
|
+
_bundle_product_id: number;
|
|
13
|
+
bundle_variant_id: number;
|
|
14
|
+
num: number;
|
|
15
|
+
price: string | number;
|
|
16
|
+
price_type: string;
|
|
17
|
+
price_type_ext: string;
|
|
18
|
+
extension_id: number;
|
|
19
|
+
extension_type: string;
|
|
20
|
+
option: ScanOrderMoreOption[];
|
|
21
|
+
}
|
|
22
|
+
export interface ScanOrderMoreProduct {
|
|
23
|
+
product_id: number | null;
|
|
24
|
+
product_variant_id: number;
|
|
25
|
+
num: number;
|
|
26
|
+
note: string;
|
|
27
|
+
key: string;
|
|
28
|
+
rowKey: string;
|
|
29
|
+
unique: string;
|
|
30
|
+
session: null;
|
|
31
|
+
option: ScanOrderMoreOption[];
|
|
32
|
+
bundle: ScanOrderMoreBundle[];
|
|
33
|
+
}
|
|
34
|
+
export interface ScanOrderMorePayload {
|
|
35
|
+
products: ScanOrderMoreProduct[];
|
|
36
|
+
request_unique_idempotency_token?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
39
|
+
export declare function formatScanOrderMoreProducts(products: readonly OrderSubmitProduct[]): ScanOrderMoreProduct[];
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function formatOptions() {
|
|
2
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3
|
+
return options.map(function (option) {
|
|
4
|
+
var _option$option_group_, _option$num, _ref, _option$add_price;
|
|
5
|
+
return {
|
|
6
|
+
product_option_item_id: (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id,
|
|
7
|
+
option_group_id: option.option_group_id,
|
|
8
|
+
num: (_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : 1,
|
|
9
|
+
price: (_ref = (_option$add_price = option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option.price) !== null && _ref !== void 0 ? _ref : 0
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
15
|
+
export function formatScanOrderMoreProducts(products) {
|
|
16
|
+
return products.map(function (product, index) {
|
|
17
|
+
var _product$metadata, _product$note, _product$product_sku;
|
|
18
|
+
// Canonical cart rows already have a UID. Keep old UID-less snapshots stable
|
|
19
|
+
// within the same request without merging distinct rows of the same SKU.
|
|
20
|
+
var lineKey = String(((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number) || "scan-order-more:".concat(product.product_id, ":").concat(product.product_variant_id, ":").concat(index));
|
|
21
|
+
return {
|
|
22
|
+
product_id: product.product_id,
|
|
23
|
+
product_variant_id: product.product_variant_id,
|
|
24
|
+
num: product.product_quantity,
|
|
25
|
+
note: String((_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : ''),
|
|
26
|
+
key: lineKey,
|
|
27
|
+
rowKey: lineKey,
|
|
28
|
+
unique: lineKey,
|
|
29
|
+
session: null,
|
|
30
|
+
option: formatOptions((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option),
|
|
31
|
+
bundle: (product.product_bundle || []).map(function (bundle) {
|
|
32
|
+
var _bundle$bundle_varian, _ref2, _bundle$num, _bundle$price, _bundle$price_type, _bundle$price_type_ex, _bundle$extension_id, _bundle$extension_typ;
|
|
33
|
+
return {
|
|
34
|
+
id: bundle.bundle_id,
|
|
35
|
+
group_id: bundle.bundle_group_id,
|
|
36
|
+
// V1 calls the selection/map ID bundle_product_id; the actual child
|
|
37
|
+
// product ID is stored separately as _bundle_product_id.
|
|
38
|
+
bundle_product_id: bundle.bundle_id,
|
|
39
|
+
_bundle_product_id: bundle.bundle_product_id,
|
|
40
|
+
bundle_variant_id: (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : 0,
|
|
41
|
+
num: (_ref2 = (_bundle$num = bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle.quantity) !== null && _ref2 !== void 0 ? _ref2 : 1,
|
|
42
|
+
price: (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : 0,
|
|
43
|
+
price_type: (_bundle$price_type = bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
44
|
+
price_type_ext: (_bundle$price_type_ex = bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : '',
|
|
45
|
+
extension_id: (_bundle$extension_id = bundle.extension_id) !== null && _bundle$extension_id !== void 0 ? _bundle$extension_id : 0,
|
|
46
|
+
extension_type: (_bundle$extension_typ = bundle.extension_type) !== null && _bundle$extension_typ !== void 0 ? _bundle$extension_typ : 'normal',
|
|
47
|
+
option: formatOptions(bundle.option)
|
|
48
|
+
};
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -40,6 +40,7 @@ import { composeLinePrice, buildSubmitPayload, createUuidV4, getProductSkuOption
|
|
|
40
40
|
import dayjs from 'dayjs';
|
|
41
41
|
import { ItemRuleEvaluator } from "../../model/strategy/adapter/itemRule";
|
|
42
42
|
import { prepareScanOrderMenuAvailability, ScanOrderMenuAvailabilityError } from "./menuAvailability";
|
|
43
|
+
import { formatScanOrderMoreProducts } from "./additionalOrderPayload";
|
|
43
44
|
export * from "./types";
|
|
44
45
|
function isItemRewardProductDiscount(discount) {
|
|
45
46
|
var _discount$metadata, _discount$metadata2;
|
|
@@ -1522,7 +1523,7 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1522
1523
|
value: function () {
|
|
1523
1524
|
var _submitScanOrderMore = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
1524
1525
|
var _this$otherParams8, _this$otherParams9, _this$otherParams10, _this$otherParams11, _this$otherParams12;
|
|
1525
|
-
var tempOrder, enhancePayload, latestSummary, payload, products, orderId, result;
|
|
1526
|
+
var tempOrder, enhancePayload, latestSummary, payload, products, orderId, requestBody, result;
|
|
1526
1527
|
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1527
1528
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1528
1529
|
case 0:
|
|
@@ -1555,19 +1556,20 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1555
1556
|
summary: latestSummary,
|
|
1556
1557
|
enhance: enhancePayload
|
|
1557
1558
|
});
|
|
1558
|
-
products = filterProductsForScanOrderMore(payload.products);
|
|
1559
|
+
products = formatScanOrderMoreProducts(filterProductsForScanOrderMore(payload.products));
|
|
1559
1560
|
orderId = tempOrder.order_id;
|
|
1560
|
-
|
|
1561
|
-
return this.request.put("/order/order/product/".concat(orderId), {
|
|
1561
|
+
requestBody = {
|
|
1562
1562
|
products: products,
|
|
1563
1563
|
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
1564
|
-
}
|
|
1564
|
+
};
|
|
1565
|
+
_context17.next = 14;
|
|
1566
|
+
return this.request.put("/order/order/product/".concat(orderId), requestBody, {
|
|
1565
1567
|
customToast: function customToast() {}
|
|
1566
1568
|
});
|
|
1567
|
-
case
|
|
1569
|
+
case 14:
|
|
1568
1570
|
result = _context17.sent;
|
|
1569
1571
|
if (!((result === null || result === void 0 ? void 0 : result.code) === 200 && !(result !== null && result !== void 0 && result.data))) {
|
|
1570
|
-
_context17.next =
|
|
1572
|
+
_context17.next = 17;
|
|
1571
1573
|
break;
|
|
1572
1574
|
}
|
|
1573
1575
|
return _context17.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -1575,9 +1577,9 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseSalesImpl) {
|
|
|
1575
1577
|
order_id: orderId
|
|
1576
1578
|
}
|
|
1577
1579
|
}));
|
|
1578
|
-
case 16:
|
|
1579
|
-
return _context17.abrupt("return", result);
|
|
1580
1580
|
case 17:
|
|
1581
|
+
return _context17.abrupt("return", result);
|
|
1582
|
+
case 18:
|
|
1581
1583
|
case "end":
|
|
1582
1584
|
return _context17.stop();
|
|
1583
1585
|
}
|
|
@@ -644,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
644
644
|
generateIdempotencyToken(): string;
|
|
645
645
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
646
646
|
createOrder(params: CommitOrderParams['query']): {
|
|
647
|
-
type: "
|
|
647
|
+
type: "appointment_booking" | "virtual";
|
|
648
648
|
platform: string;
|
|
649
649
|
sales_channel: string;
|
|
650
650
|
order_sales_channel: string;
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 | 1 | 2 |
|
|
345
|
+
weekNum: 0 | 1 | 2 | 6 | 4 | 5 | 3;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -295,6 +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 withAccountNameFallback;
|
|
298
299
|
private prefillOrderCustomerContactInfo;
|
|
299
300
|
protected waitForOrderCustomerContactInfo(): Promise<void>;
|
|
300
301
|
validateContactInfo(): Promise<void>;
|
|
@@ -373,7 +374,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
373
374
|
* 获取当前的客户搜索条件
|
|
374
375
|
* @returns 当前搜索条件
|
|
375
376
|
*/
|
|
376
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
377
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
377
378
|
/**
|
|
378
379
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
379
380
|
* @returns 客户状态
|
|
@@ -1168,21 +1168,41 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1168
1168
|
tempOrder: this.getTempOrder()
|
|
1169
1169
|
});
|
|
1170
1170
|
}
|
|
1171
|
+
withAccountNameFallback(contact, customer) {
|
|
1172
|
+
let next = contact;
|
|
1173
|
+
// Saved booking contacts take precedence. Only missing name fields fall back
|
|
1174
|
+
// to the account profile; phone/email keep their existing contact-info source.
|
|
1175
|
+
for (const field of ['first_name', 'last_name']) {
|
|
1176
|
+
if (typeof contact?.[field] === 'string' && contact[field].trim()) continue;
|
|
1177
|
+
const name = customer[field];
|
|
1178
|
+
if (typeof name !== 'string' || !name.trim()) continue;
|
|
1179
|
+
if (next === contact) next = {
|
|
1180
|
+
...contact
|
|
1181
|
+
};
|
|
1182
|
+
next[field] = name.trim();
|
|
1183
|
+
}
|
|
1184
|
+
return next;
|
|
1185
|
+
}
|
|
1171
1186
|
prefillOrderCustomerContactInfo(customer, customerChanged) {
|
|
1172
1187
|
const order = this.getTempOrder();
|
|
1173
1188
|
const customerId = Number(order?.customer_id);
|
|
1174
|
-
if (!order || !Number.isInteger(customerId) || customerId <= 1 || order.
|
|
1189
|
+
if (!order || !Number.isInteger(customerId) || customerId <= 1 || order._extend?.contactInfoEdited) return;
|
|
1175
1190
|
// A restored new cart may already have its customer ID. Existing sales keep their snapshot,
|
|
1176
1191
|
// even when it is empty; only an explicit customer switch replaces it.
|
|
1177
1192
|
if (!customerChanged && order.order_id && !String(order.order_id).startsWith('local_order')) return;
|
|
1178
|
-
const contact = (0, _contactInfo.extractCustomerContactInfo)(customer);
|
|
1193
|
+
const contact = order.contacts_info ?? (0, _contactInfo.extractCustomerContactInfo)(customer);
|
|
1179
1194
|
if (contact) {
|
|
1180
1195
|
this.orderCustomerContactRequest = null;
|
|
1181
|
-
|
|
1196
|
+
const next = this.withAccountNameFallback(contact, customer);
|
|
1197
|
+
if (next !== order.contacts_info) void this.applyDefaultOrderCustomerContactInfo(next);
|
|
1182
1198
|
return;
|
|
1183
1199
|
}
|
|
1184
1200
|
// A relation explicitly returned as null is authoritative. Only a missing relation needs fetching.
|
|
1185
|
-
if (customer.contacts_info !== undefined)
|
|
1201
|
+
if (customer.contacts_info !== undefined) {
|
|
1202
|
+
const next = this.withAccountNameFallback(null, customer);
|
|
1203
|
+
if (next) void this.applyDefaultOrderCustomerContactInfo(next);
|
|
1204
|
+
return;
|
|
1205
|
+
}
|
|
1186
1206
|
const userPlatform = (0, _platform.isCustomerUserPlatform)(this.otherParams?.platform);
|
|
1187
1207
|
const getAuthenticatedCustomerId = () => Number(this.core?.getPlugin?.('user')?.get?.()?.id);
|
|
1188
1208
|
if (userPlatform && getAuthenticatedCustomerId() !== customerId) return;
|
|
@@ -1208,12 +1228,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1208
1228
|
}
|
|
1209
1229
|
// POS and physical Kiosk share the /shop request plugin and current-shop customer resolver.
|
|
1210
1230
|
const resolved = await this.resolveCustomerById(customerId);
|
|
1211
|
-
return Number(resolved
|
|
1231
|
+
return resolved && Number(resolved.id) === customerId ? this.withAccountNameFallback((0, _contactInfo.extractCustomerContactInfo)(resolved), resolved) : null;
|
|
1212
1232
|
};
|
|
1213
1233
|
pending.promise = loadContact().then(async value => {
|
|
1214
1234
|
const current = this.getTempOrder();
|
|
1215
1235
|
if (this.orderCustomerContactRequest !== pending || this.getCustomerContactOrderKey() !== orderKey || Number(current?.customer_id) !== customerId || scope !== this.getCustomerContactScope() || current?._extend?.contactInfoEdited || current?.contacts_info != null || userPlatform && getAuthenticatedCustomerId() !== customerId) return;
|
|
1216
|
-
|
|
1236
|
+
const next = this.withAccountNameFallback(value, customer);
|
|
1237
|
+
if (next) await this.applyDefaultOrderCustomerContactInfo(next);
|
|
1217
1238
|
}).catch(() => {
|
|
1218
1239
|
// A failed default does not prevent manual entry; a subsequent sync can retry.
|
|
1219
1240
|
if (this.orderCustomerContactRequest === pending) this.orderCustomerContactRequest = null;
|
|
@@ -25,27 +25,19 @@ 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;
|
|
29
28
|
metadata: Record<string, any>;
|
|
30
|
-
business_code?: string | undefined;
|
|
31
|
-
status: string;
|
|
32
29
|
note: string;
|
|
33
|
-
holder: Record<string, any> | null;
|
|
34
|
-
customer_id: number | null;
|
|
35
|
-
bookings: any[];
|
|
36
|
-
payments: any[];
|
|
37
|
-
contacts_info: Record<string, any> | null;
|
|
38
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
39
|
-
refunds?: any[] | undefined;
|
|
40
|
-
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
41
30
|
order_id: number | null;
|
|
42
|
-
external_sale_number: string;
|
|
43
31
|
order_number: string | null;
|
|
44
32
|
shop_order_number: string | null;
|
|
45
33
|
shop_full_order_number: string | null;
|
|
34
|
+
type: string;
|
|
35
|
+
business_code?: string | undefined;
|
|
46
36
|
sales_channel: string;
|
|
47
37
|
order_sales_channel: string;
|
|
38
|
+
status: string;
|
|
48
39
|
shipping_status: string;
|
|
40
|
+
customer_id: number | null;
|
|
49
41
|
customer_name: string;
|
|
50
42
|
country_calling_code: string;
|
|
51
43
|
phone: string;
|
|
@@ -64,9 +56,17 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
64
56
|
delivery_type?: string | undefined;
|
|
65
57
|
table_number?: Record<string, any> | undefined;
|
|
66
58
|
schedule_date: string;
|
|
59
|
+
bookings: any[];
|
|
60
|
+
payments: any[];
|
|
67
61
|
surcharges: any[];
|
|
68
62
|
relation_forms: any[];
|
|
69
63
|
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;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { OrderSubmitProduct } from '../../modules/Order/types';
|
|
2
|
+
interface ScanOrderMoreOption {
|
|
3
|
+
product_option_item_id: number;
|
|
4
|
+
option_group_id: number;
|
|
5
|
+
num: number;
|
|
6
|
+
price: string | number;
|
|
7
|
+
}
|
|
8
|
+
interface ScanOrderMoreBundle {
|
|
9
|
+
id: number;
|
|
10
|
+
group_id: number;
|
|
11
|
+
bundle_product_id: number;
|
|
12
|
+
_bundle_product_id: number;
|
|
13
|
+
bundle_variant_id: number;
|
|
14
|
+
num: number;
|
|
15
|
+
price: string | number;
|
|
16
|
+
price_type: string;
|
|
17
|
+
price_type_ext: string;
|
|
18
|
+
extension_id: number;
|
|
19
|
+
extension_type: string;
|
|
20
|
+
option: ScanOrderMoreOption[];
|
|
21
|
+
}
|
|
22
|
+
export interface ScanOrderMoreProduct {
|
|
23
|
+
product_id: number | null;
|
|
24
|
+
product_variant_id: number;
|
|
25
|
+
num: number;
|
|
26
|
+
note: string;
|
|
27
|
+
key: string;
|
|
28
|
+
rowKey: string;
|
|
29
|
+
unique: string;
|
|
30
|
+
session: null;
|
|
31
|
+
option: ScanOrderMoreOption[];
|
|
32
|
+
bundle: ScanOrderMoreBundle[];
|
|
33
|
+
}
|
|
34
|
+
export interface ScanOrderMorePayload {
|
|
35
|
+
products: ScanOrderMoreProduct[];
|
|
36
|
+
request_unique_idempotency_token?: string;
|
|
37
|
+
}
|
|
38
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
39
|
+
export declare function formatScanOrderMoreProducts(products: readonly OrderSubmitProduct[]): ScanOrderMoreProduct[];
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatScanOrderMoreProducts = formatScanOrderMoreProducts;
|
|
7
|
+
function formatOptions(options = []) {
|
|
8
|
+
return options.map(option => ({
|
|
9
|
+
product_option_item_id: option.option_group_item_id ?? option.product_option_item_id,
|
|
10
|
+
option_group_id: option.option_group_id,
|
|
11
|
+
num: option.num ?? 1,
|
|
12
|
+
price: option.add_price ?? option.price ?? 0
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The add-on PUT still consumes V1 selections, while checkout consumes V2 products. */
|
|
17
|
+
function formatScanOrderMoreProducts(products) {
|
|
18
|
+
return products.map((product, index) => {
|
|
19
|
+
// Canonical cart rows already have a UID. Keep old UID-less snapshots stable
|
|
20
|
+
// within the same request without merging distinct rows of the same SKU.
|
|
21
|
+
const lineKey = String(product.metadata?.unique_identification_number || `scan-order-more:${product.product_id}:${product.product_variant_id}:${index}`);
|
|
22
|
+
return {
|
|
23
|
+
product_id: product.product_id,
|
|
24
|
+
product_variant_id: product.product_variant_id,
|
|
25
|
+
num: product.product_quantity,
|
|
26
|
+
note: String(product.note ?? ''),
|
|
27
|
+
key: lineKey,
|
|
28
|
+
rowKey: lineKey,
|
|
29
|
+
unique: lineKey,
|
|
30
|
+
session: null,
|
|
31
|
+
option: formatOptions(product.product_sku?.option),
|
|
32
|
+
bundle: (product.product_bundle || []).map(bundle => ({
|
|
33
|
+
id: bundle.bundle_id,
|
|
34
|
+
group_id: bundle.bundle_group_id,
|
|
35
|
+
// V1 calls the selection/map ID bundle_product_id; the actual child
|
|
36
|
+
// product ID is stored separately as _bundle_product_id.
|
|
37
|
+
bundle_product_id: bundle.bundle_id,
|
|
38
|
+
_bundle_product_id: bundle.bundle_product_id,
|
|
39
|
+
bundle_variant_id: bundle.bundle_variant_id ?? 0,
|
|
40
|
+
num: bundle.num ?? bundle.quantity ?? 1,
|
|
41
|
+
price: bundle.price ?? 0,
|
|
42
|
+
price_type: bundle.price_type ?? '',
|
|
43
|
+
price_type_ext: bundle.price_type_ext ?? '',
|
|
44
|
+
extension_id: bundle.extension_id ?? 0,
|
|
45
|
+
extension_type: bundle.extension_type ?? 'normal',
|
|
46
|
+
option: formatOptions(bundle.option)
|
|
47
|
+
}))
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -32,6 +32,7 @@ var _utils2 = require("../../modules/Order/utils");
|
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _itemRule = require("../../model/strategy/adapter/itemRule");
|
|
34
34
|
var _menuAvailability = require("./menuAvailability");
|
|
35
|
+
var _additionalOrderPayload = require("./additionalOrderPayload");
|
|
35
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
36
37
|
function isItemRewardProductDiscount(discount) {
|
|
37
38
|
return discount?.type === 'product' && discount?.metadata?.source === 'promotion' && discount?.metadata?.actionType === 'ITEM_REWARD';
|
|
@@ -993,12 +994,13 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
993
994
|
summary: latestSummary,
|
|
994
995
|
enhance: enhancePayload
|
|
995
996
|
});
|
|
996
|
-
const products = (0, _utils.filterProductsForScanOrderMore)(payload.products);
|
|
997
|
+
const products = (0, _additionalOrderPayload.formatScanOrderMoreProducts)((0, _utils.filterProductsForScanOrderMore)(payload.products));
|
|
997
998
|
const orderId = tempOrder.order_id;
|
|
998
|
-
const
|
|
999
|
+
const requestBody = {
|
|
999
1000
|
products,
|
|
1000
1001
|
request_unique_idempotency_token: payload.request_unique_idempotency_token
|
|
1001
|
-
}
|
|
1002
|
+
};
|
|
1003
|
+
const result = await this.request.put(`/order/order/product/${orderId}`, requestBody, {
|
|
1002
1004
|
customToast: () => {}
|
|
1003
1005
|
});
|
|
1004
1006
|
if (result?.code === 200 && !result?.data) {
|