@pisell/pisellos 2.3.227 → 2.3.228
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/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/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- 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;
|
|
@@ -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
|
}
|
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _adapter.PromotionAdapter;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _evaluator.PromotionEvaluator;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "default", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _adapter.default;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _evaluator = require("./evaluator");
|
|
43
|
+
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
+
var _examples = require("./examples");
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -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;
|
|
@@ -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) {
|