@pisell/pisellos 2.2.163 → 2.2.165
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/index.d.ts +37 -0
- package/dist/modules/BookingContext/index.js +436 -0
- package/dist/modules/BookingContext/types.d.ts +102 -0
- package/dist/modules/BookingContext/types.js +51 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +157 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +137 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +191 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/flexible.js +56 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
- package/dist/modules/BookingContext/utils/index.d.ts +11 -0
- package/dist/modules/BookingContext/utils/index.js +11 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/noResource.js +77 -0
- package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/dist/modules/BookingContext/utils/productExtend.js +339 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
- package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
- package/dist/modules/BookingContext/utils/resources.js +486 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
- package/dist/modules/Customer/index.js +23 -22
- package/dist/modules/Discount/index.js +4 -3
- package/dist/modules/Order/index.d.ts +25 -7
- package/dist/modules/Order/index.js +608 -291
- package/dist/modules/Order/types.d.ts +46 -14
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +76 -23
- package/dist/modules/SalesSummary/index.js +4 -2
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +46 -7
- package/dist/solution/BaseSales/index.js +928 -312
- package/dist/solution/BaseSales/types.d.ts +51 -1
- package/dist/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/dist/solution/BaseSales/utils/quotationPrice.js +159 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +124 -1
- package/dist/solution/BookingTicket/index.js +488 -90
- package/dist/solution/BookingTicket/types.d.ts +2 -0
- package/dist/solution/BookingTicket/types.js +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +334 -0
- package/dist/solution/ScanOrder/index.d.ts +9 -3
- package/dist/solution/ScanOrder/index.js +231 -128
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/dist/solution/VenueBooking/index.d.ts +4 -2
- package/dist/solution/VenueBooking/index.js +103 -55
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/lib/modules/BookingContext/index.d.ts +37 -0
- package/lib/modules/BookingContext/index.js +297 -0
- package/lib/modules/BookingContext/types.d.ts +102 -0
- package/lib/modules/BookingContext/types.js +34 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +174 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +141 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +65 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +177 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/flexible.js +80 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/formatResourceList.js +50 -0
- package/lib/modules/BookingContext/utils/index.d.ts +11 -0
- package/lib/modules/BookingContext/utils/index.js +43 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/noResource.js +90 -0
- package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
- package/lib/modules/BookingContext/utils/productExtend.js +283 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/resourceSelection.js +46 -0
- package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
- package/lib/modules/BookingContext/utils/resources.js +377 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/serviceTimes.js +162 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/BookingContext/utils/timeSlices.js +124 -0
- package/lib/modules/Customer/index.js +8 -8
- package/lib/modules/Discount/index.js +5 -1
- package/lib/modules/Order/index.d.ts +25 -7
- package/lib/modules/Order/index.js +268 -72
- package/lib/modules/Order/types.d.ts +46 -14
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +66 -15
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +3 -1
- package/lib/solution/BaseSales/index.d.ts +46 -7
- package/lib/solution/BaseSales/index.js +369 -17
- package/lib/solution/BaseSales/types.d.ts +51 -1
- package/lib/solution/BaseSales/utils/quotationPrice.d.ts +7 -0
- package/lib/solution/BaseSales/utils/quotationPrice.js +201 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +124 -1
- package/lib/solution/BookingTicket/index.js +255 -8
- package/lib/solution/BookingTicket/types.d.ts +2 -0
- package/lib/solution/BookingTicket/types.js +6 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +111 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +308 -0
- package/lib/solution/ScanOrder/index.d.ts +9 -3
- package/lib/solution/ScanOrder/index.js +147 -66
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/lib/solution/VenueBooking/index.d.ts +4 -2
- package/lib/solution/VenueBooking/index.js +50 -14
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +10 -0
- package/package.json +1 -1
|
@@ -103,11 +103,11 @@ export interface OrderSummary {
|
|
|
103
103
|
export interface OrderTempOrder {
|
|
104
104
|
order_id: number | null;
|
|
105
105
|
external_sale_number: string;
|
|
106
|
-
order_number: string;
|
|
107
|
-
shop_order_number: string;
|
|
108
|
-
shop_full_order_number: string;
|
|
106
|
+
order_number: string | null;
|
|
107
|
+
shop_order_number: string | null;
|
|
108
|
+
shop_full_order_number: string | null;
|
|
109
109
|
type: string;
|
|
110
|
-
business_code
|
|
110
|
+
business_code?: string;
|
|
111
111
|
platform: string;
|
|
112
112
|
sales_channel: string;
|
|
113
113
|
order_sales_channel: string;
|
|
@@ -157,7 +157,7 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
|
|
|
157
157
|
payment_price: string;
|
|
158
158
|
product_sku: Record<string, any>;
|
|
159
159
|
}
|
|
160
|
-
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer'
|
|
160
|
+
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer'> {
|
|
161
161
|
platform: string;
|
|
162
162
|
request_unique_idempotency_token?: string;
|
|
163
163
|
form_record_ids?: Array<{
|
|
@@ -176,16 +176,32 @@ export interface OrderState {
|
|
|
176
176
|
discount: DiscountModule | null;
|
|
177
177
|
rules: RulesModule | null;
|
|
178
178
|
}
|
|
179
|
+
export interface ReplaceTempOrderOptions {
|
|
180
|
+
recalculateSummary?: boolean;
|
|
181
|
+
persist?: boolean;
|
|
182
|
+
saveDraft?: boolean;
|
|
183
|
+
}
|
|
184
|
+
export type AddProductBookingInput = Record<string, any>;
|
|
179
185
|
/** 更新购物车行:仅传 SKU 时命中同 SKU 第一行;多行同 SKU 须传 unique_identification_number / 选项指纹等 */
|
|
180
|
-
export interface
|
|
186
|
+
export interface UpdateOrderProductParams {
|
|
181
187
|
product_id: number | null;
|
|
182
188
|
product_variant_id: number;
|
|
183
189
|
updates: Partial<OrderProduct>;
|
|
184
190
|
unique_identification_number?: string;
|
|
191
|
+
identity_key?: string;
|
|
185
192
|
product_option_item?: any[];
|
|
186
193
|
product_bundle?: any[];
|
|
194
|
+
booking?: AddProductBookingInput;
|
|
195
|
+
}
|
|
196
|
+
/** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
|
|
197
|
+
export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
|
|
198
|
+
num: number;
|
|
199
|
+
identity_key?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface UpdateOrderBookingParams {
|
|
202
|
+
unique_identification_number: string;
|
|
203
|
+
updates: AddProductBookingInput;
|
|
187
204
|
}
|
|
188
|
-
export type AddProductBookingInput = Record<string, any>;
|
|
189
205
|
export interface OrderProductMergeDecisionContext {
|
|
190
206
|
incomingProduct: Partial<OrderProduct> & OrderProductIdentity;
|
|
191
207
|
normalizedIncoming: OrderProduct;
|
|
@@ -236,10 +252,11 @@ export interface SubmitSalesOrderParams {
|
|
|
236
252
|
query: {
|
|
237
253
|
order_id: number | null;
|
|
238
254
|
external_sale_number: string;
|
|
239
|
-
order_number: string;
|
|
240
|
-
shop_order_number: string;
|
|
255
|
+
order_number: string | null;
|
|
256
|
+
shop_order_number: string | null;
|
|
257
|
+
shop_full_order_number: string | null;
|
|
241
258
|
type: string;
|
|
242
|
-
business_code
|
|
259
|
+
business_code?: string;
|
|
243
260
|
platform: string;
|
|
244
261
|
request_unique_idempotency_token?: string;
|
|
245
262
|
sales_channel: string;
|
|
@@ -350,6 +367,7 @@ export interface SyncPaymentsToOrderParams {
|
|
|
350
367
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
351
368
|
submitWhenPaid?: boolean;
|
|
352
369
|
smallTicketDataFlag?: number;
|
|
370
|
+
channel?: string;
|
|
353
371
|
}
|
|
354
372
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
355
373
|
isFullyPaid: boolean;
|
|
@@ -446,6 +464,7 @@ export interface OrderModuleAPI {
|
|
|
446
464
|
}) => void;
|
|
447
465
|
getTempOrder: () => OrderTempOrder | null;
|
|
448
466
|
ensureTempOrder: () => OrderTempOrder;
|
|
467
|
+
replaceTempOrder: (tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions) => Promise<OrderTempOrder>;
|
|
449
468
|
addNewOrder: () => Promise<OrderTempOrder>;
|
|
450
469
|
restoreOrder: () => OrderTempOrder;
|
|
451
470
|
getOrderProducts: () => OrderProduct[];
|
|
@@ -458,14 +477,25 @@ export interface OrderModuleAPI {
|
|
|
458
477
|
getOrderSyncState: () => OrderSyncState;
|
|
459
478
|
getOrderAmountSnapshot: () => OrderAmountSnapshot | null;
|
|
460
479
|
getTempOrderNote: () => string;
|
|
461
|
-
updateTempOrderNote:
|
|
480
|
+
updateTempOrderNote: {
|
|
481
|
+
(note: string): string;
|
|
482
|
+
(note: string, sync: true): Promise<string>;
|
|
483
|
+
(note: string, sync: boolean): string | Promise<string>;
|
|
484
|
+
};
|
|
462
485
|
updateTempOrderShopDiscount: (amount: string | number) => string;
|
|
463
486
|
updateTempOrderCustomer: (customer: UpdateTempOrderCustomerInput) => OrderSnapshot['customer'];
|
|
464
487
|
updateTempOrderBuzzer: (buzzer: string) => string;
|
|
465
488
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
466
489
|
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput) => Promise<OrderProduct[]>;
|
|
467
|
-
|
|
490
|
+
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
|
|
491
|
+
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
492
|
+
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
468
493
|
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
494
|
+
/**
|
|
495
|
+
* 仅清空购物车行:products / bookings / discount_list(保留客户、备注、支付等其它 tempOrder 字段)。
|
|
496
|
+
* 内部会 applyDiscount + recalculateSummary + persist。
|
|
497
|
+
*/
|
|
498
|
+
clearOrderCartLines: () => Promise<OrderTempOrder>;
|
|
469
499
|
persistTempOrder: () => void;
|
|
470
500
|
submitTempOrder: <T = any>(params?: {
|
|
471
501
|
cacheId?: string;
|
|
@@ -516,8 +546,10 @@ export interface OrderModuleAPI {
|
|
|
516
546
|
clearOrderCustomer: () => void;
|
|
517
547
|
loadDiscountConfig: (params: {
|
|
518
548
|
customerId: number;
|
|
519
|
-
action?: 'create';
|
|
520
|
-
|
|
549
|
+
action?: 'create' | 'edit';
|
|
550
|
+
orderId?: number;
|
|
551
|
+
apply?: boolean;
|
|
552
|
+
}) => Promise<Discount[]>;
|
|
521
553
|
getDiscountList: () => Discount[];
|
|
522
554
|
applyDiscount: () => void;
|
|
523
555
|
/**
|
|
@@ -65,6 +65,16 @@ export declare function sumOptionUnitPrice(options?: Array<{
|
|
|
65
65
|
*
|
|
66
66
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
67
67
|
*/
|
|
68
|
+
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
69
|
+
export declare function resolveRulesManualDiscountFlag(metadata: Record<string, any> | null | undefined): boolean | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* 手动改价(price_override)时行级 original_price:
|
|
72
|
+
* 购物车划线价应对齐改价前的 origin_total(如 40),而非 bundle 子项 catalog 原价合成的 30。
|
|
73
|
+
*/
|
|
74
|
+
export declare function resolveManualOverrideLineOriginalPrice(params: {
|
|
75
|
+
num?: number;
|
|
76
|
+
metadata?: Record<string, any> | null;
|
|
77
|
+
}, fallbackCompositeOriginal: string): string;
|
|
68
78
|
export declare function createDefaultOrderRulesHooks(): RulesParamsHooks;
|
|
69
79
|
/**
|
|
70
80
|
* 通过 session 类商品的开始时间结束时间生成商品的时长
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _excluded = ["unique_identification_number"],
|
|
2
2
|
_excluded2 = ["num", "product_option_item", "surcharge_fee"],
|
|
3
|
-
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "
|
|
3
|
+
_excluded3 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
|
|
4
4
|
_excluded4 = ["collect_pax", "table_occupancy_duration"];
|
|
5
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
6
6
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -113,6 +113,42 @@ export function sumOptionUnitPrice(options) {
|
|
|
113
113
|
*
|
|
114
114
|
* 导出为纯函数方便单测直接驱动钩子,不依赖 OrderModule 实例。
|
|
115
115
|
*/
|
|
116
|
+
|
|
117
|
+
/** Rules calcDiscount 用手动价标记;undefined 表示交给 Rules 用 total/origin_total 推断 */
|
|
118
|
+
export function resolveRulesManualDiscountFlag(metadata) {
|
|
119
|
+
if (!metadata) return undefined;
|
|
120
|
+
if (metadata.is_manual_discount === true || metadata.is_manual_discount === 1) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
var priceOverride = metadata.price_override;
|
|
124
|
+
if (priceOverride !== undefined && priceOverride !== null && priceOverride !== '') {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 手动改价(price_override)时行级 original_price:
|
|
132
|
+
* 购物车划线价应对齐改价前的 origin_total(如 40),而非 bundle 子项 catalog 原价合成的 30。
|
|
133
|
+
*/
|
|
134
|
+
export function resolveManualOverrideLineOriginalPrice(params, fallbackCompositeOriginal) {
|
|
135
|
+
var _metadata$origin;
|
|
136
|
+
var metadata = params.metadata || {};
|
|
137
|
+
var priceOverride = metadata.price_override;
|
|
138
|
+
if (priceOverride === undefined || priceOverride === null || priceOverride === '') {
|
|
139
|
+
return fallbackCompositeOriginal;
|
|
140
|
+
}
|
|
141
|
+
var refTotal = (_metadata$origin = metadata.origin) === null || _metadata$origin === void 0 || (_metadata$origin = _metadata$origin._extend) === null || _metadata$origin === void 0 ? void 0 : _metadata$origin.origin_total;
|
|
142
|
+
if (refTotal === undefined || refTotal === null || refTotal === '') {
|
|
143
|
+
return fallbackCompositeOriginal;
|
|
144
|
+
}
|
|
145
|
+
var parsed = Number(refTotal);
|
|
146
|
+
if (!Number.isFinite(parsed)) {
|
|
147
|
+
return fallbackCompositeOriginal;
|
|
148
|
+
}
|
|
149
|
+
var num = Number(params.num) > 0 ? Number(params.num) : 1;
|
|
150
|
+
return new Decimal(parsed).dividedBy(num).toDecimalPlaces(2).toFixed(2);
|
|
151
|
+
}
|
|
116
152
|
export function createDefaultOrderRulesHooks() {
|
|
117
153
|
var toUnitPriceString = function toUnitPriceString(totalLike, num) {
|
|
118
154
|
var effectiveNum = Number(num) > 0 ? Number(num) : 1;
|
|
@@ -120,7 +156,7 @@ export function createDefaultOrderRulesHooks() {
|
|
|
120
156
|
};
|
|
121
157
|
return {
|
|
122
158
|
getProduct: function getProduct(product) {
|
|
123
|
-
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5
|
|
159
|
+
var _product$metadata, _product$metadata2, _product$metadata3, _product$metadata4, _product$metadata5;
|
|
124
160
|
// source_product_price 是权威源;兜底链:source → mainSelling − options(反推)→ 行 selling_price
|
|
125
161
|
var metadataAny = product.metadata || {};
|
|
126
162
|
var optionSum = sumOptionUnitPrice(product.product_option_item);
|
|
@@ -161,9 +197,11 @@ export function createDefaultOrderRulesHooks() {
|
|
|
161
197
|
bundle: product.product_bundle || [],
|
|
162
198
|
booking_id: ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_id) || null,
|
|
163
199
|
isClient: false,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
200
|
+
// 勿写死 false:否则 Rules 不会走 total≠origin_total 的手动价推断,
|
|
201
|
+
// 无券时会把 bundle 价还原成 original_price(手动改价套餐会从 20 回到 30)。
|
|
202
|
+
isManualDiscount: resolveRulesManualDiscountFlag(metadataAny),
|
|
203
|
+
holder_id: (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.holder_id,
|
|
204
|
+
startDate: ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.start_date) || ((_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.startDate)
|
|
167
205
|
};
|
|
168
206
|
},
|
|
169
207
|
setProduct: function setProduct(product, values) {
|
|
@@ -196,9 +234,13 @@ export function createDefaultOrderRulesHooks() {
|
|
|
196
234
|
bundle: nextBundle,
|
|
197
235
|
useOriginalBundle: true
|
|
198
236
|
});
|
|
237
|
+
var finalOriginalPrice = resolveManualOverrideLineOriginalPrice({
|
|
238
|
+
num: nextNum,
|
|
239
|
+
metadata: metadataAny
|
|
240
|
+
}, composedOriginalPrice);
|
|
199
241
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
200
242
|
selling_price: composedSellingPrice,
|
|
201
|
-
original_price:
|
|
243
|
+
original_price: finalOriginalPrice,
|
|
202
244
|
discount_list: (_values$discount_list = values.discount_list) !== null && _values$discount_list !== void 0 ? _values$discount_list : product.discount_list,
|
|
203
245
|
num: (_values$quantity2 = values.quantity) !== null && _values$quantity2 !== void 0 ? _values$quantity2 : product.num,
|
|
204
246
|
product_bundle: nextBundle,
|
|
@@ -502,18 +544,18 @@ export function createDefaultTempOrder(params) {
|
|
|
502
544
|
return {
|
|
503
545
|
order_id: null,
|
|
504
546
|
external_sale_number: '',
|
|
505
|
-
order_number:
|
|
506
|
-
shop_order_number:
|
|
507
|
-
shop_full_order_number:
|
|
508
|
-
type: '
|
|
509
|
-
business_code:
|
|
547
|
+
order_number: null,
|
|
548
|
+
shop_order_number: null,
|
|
549
|
+
shop_full_order_number: null,
|
|
550
|
+
type: '',
|
|
551
|
+
business_code: undefined,
|
|
510
552
|
platform: 'h5',
|
|
511
553
|
sales_channel: 'my_pisel',
|
|
512
554
|
order_sales_channel: 'online_store',
|
|
513
555
|
status: 'normal',
|
|
514
556
|
payment_status: 'payment_processing',
|
|
515
557
|
shipping_status: 'unfulfilled',
|
|
516
|
-
customer_id:
|
|
558
|
+
customer_id: 0,
|
|
517
559
|
customer_name: '',
|
|
518
560
|
country_calling_code: '',
|
|
519
561
|
phone: '',
|
|
@@ -548,7 +590,7 @@ export function createDefaultTempOrder(params) {
|
|
|
548
590
|
};
|
|
549
591
|
}
|
|
550
592
|
export function buildSubmitPayload(params) {
|
|
551
|
-
var _ref10,
|
|
593
|
+
var _ref10, _tempOrder$is_price_i, _tempOrder$is_deposit;
|
|
552
594
|
var tempOrder = params.tempOrder,
|
|
553
595
|
cacheId = params.cacheId,
|
|
554
596
|
_params$now = params.now,
|
|
@@ -573,20 +615,32 @@ export function buildSubmitPayload(params) {
|
|
|
573
615
|
_shopServiceType = _ref9.shop_service_type,
|
|
574
616
|
_startTime = _ref9.start_time,
|
|
575
617
|
_customer = _ref9.customer,
|
|
576
|
-
_shopFullOrderNumber = _ref9.shop_full_order_number,
|
|
577
618
|
_rootTaxFee = _ref9.tax_fee,
|
|
578
619
|
_totalAmount = _ref9.total_amount,
|
|
579
620
|
_totalRefundAmount = _ref9.total_refund_amount,
|
|
580
621
|
_createDate = _ref9.create_date,
|
|
581
622
|
_holderId = _ref9.holder_id,
|
|
582
623
|
tempOrderRest = _objectWithoutProperties(_ref9, _excluded3);
|
|
624
|
+
var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
|
|
625
|
+
if (!submitType) {
|
|
626
|
+
var _tempOrder$bookings;
|
|
627
|
+
// 如果外部没有传递 types,根据订单里当前是否有 bookings 来决定是 appointment_booking 还是 virtual
|
|
628
|
+
if (tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.length) {
|
|
629
|
+
submitType = 'appointment_booking';
|
|
630
|
+
} else {
|
|
631
|
+
submitType = 'virtual';
|
|
632
|
+
}
|
|
633
|
+
}
|
|
583
634
|
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
635
|
+
order_number: null,
|
|
636
|
+
shop_order_number: null,
|
|
637
|
+
shop_full_order_number: null,
|
|
584
638
|
platform: normalizeSubmitPlatform(platform),
|
|
585
639
|
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
586
|
-
type:
|
|
587
|
-
business_code:
|
|
640
|
+
type: submitType,
|
|
641
|
+
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
588
642
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
589
|
-
order_sales_channel: (
|
|
643
|
+
order_sales_channel: (_ref10 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref10 !== void 0 ? _ref10 : 'online_store',
|
|
590
644
|
status: tempOrder.status || 'normal',
|
|
591
645
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
592
646
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -601,8 +655,7 @@ export function buildSubmitPayload(params) {
|
|
|
601
655
|
schedule_date: scheduleDate,
|
|
602
656
|
created_at: tempOrder.created_at || formatDateTime(now),
|
|
603
657
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
604
|
-
|
|
605
|
-
return Number((_parent_id = booking.parent_id) !== null && _parent_id !== void 0 ? _parent_id : 0) !== 0;
|
|
658
|
+
return Number(booking.parent_id) !== 0;
|
|
606
659
|
}).map(function (booking) {
|
|
607
660
|
return normalizeSubmitBooking(booking);
|
|
608
661
|
}),
|
|
@@ -614,10 +667,10 @@ export function buildSubmitPayload(params) {
|
|
|
614
667
|
// holder: tempOrder.holder || null,
|
|
615
668
|
// summary,
|
|
616
669
|
metadata: function () {
|
|
617
|
-
var
|
|
618
|
-
_collectPax =
|
|
619
|
-
_tableOccupancyDuration =
|
|
620
|
-
rest = _objectWithoutProperties(
|
|
670
|
+
var _ref11 = tempOrder.metadata || {},
|
|
671
|
+
_collectPax = _ref11.collect_pax,
|
|
672
|
+
_tableOccupancyDuration = _ref11.table_occupancy_duration,
|
|
673
|
+
rest = _objectWithoutProperties(_ref11, _excluded4);
|
|
621
674
|
return _objectSpread({}, rest);
|
|
622
675
|
}(),
|
|
623
676
|
products: (tempOrder.products || []).map(function (product) {
|
|
@@ -27,7 +27,8 @@ export * from "./types";
|
|
|
27
27
|
var salesSummaryDataKeys = {
|
|
28
28
|
isPriceIncludeTax: 'is_price_include_tax',
|
|
29
29
|
taxRate: 'tax_rate',
|
|
30
|
-
taxTitle: 'tax_title'
|
|
30
|
+
taxTitle: 'tax_title',
|
|
31
|
+
taxCountryCode: 'tax_country_code'
|
|
31
32
|
};
|
|
32
33
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
33
34
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
@@ -135,7 +136,8 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
135
136
|
return {
|
|
136
137
|
isPriceIncludeTax: this.getAppData(salesSummaryDataKeys.isPriceIncludeTax),
|
|
137
138
|
taxRate: this.getAppData(salesSummaryDataKeys.taxRate),
|
|
138
|
-
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle)
|
|
139
|
+
taxTitle: this.getAppData(salesSummaryDataKeys.taxTitle),
|
|
140
|
+
taxCountryCode: this.getAppData(salesSummaryDataKeys.taxCountryCode)
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
143
|
}, {
|
package/dist/modules/index.d.ts
CHANGED
package/dist/modules/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesScanCodeResult } from './types';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
|
-
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput,
|
|
5
|
+
import type { AddProductBookingInput, LoadSalesDetailParams, OrderPaymentData, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder } from '../../modules/Order/types';
|
|
6
6
|
import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
|
|
7
7
|
import type { Discount } from '../../modules/Discount/types';
|
|
8
8
|
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
@@ -11,6 +11,7 @@ import { ProductList } from '../../modules/ProductList';
|
|
|
11
11
|
import { PaymentModule } from '../../modules/Payment';
|
|
12
12
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
13
13
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
14
|
+
import { QuotationModule } from '../../modules/Quotation';
|
|
14
15
|
import type { ISalesDetail, ISalesDetailHeader, ISalesBooking, ISalesPayment, ISalesSurcharge } from './utils/parseSalesResponse';
|
|
15
16
|
import { type TransformBaseProductToOrderProductParams } from './utils/transformBaseProductToOrderProduct';
|
|
16
17
|
export interface BaseSalesState {
|
|
@@ -19,6 +20,7 @@ export interface BaseSalesState {
|
|
|
19
20
|
payment?: PaymentModule;
|
|
20
21
|
salesSummary?: SalesSummaryModule;
|
|
21
22
|
schedule?: ScheduleModule;
|
|
23
|
+
quotation?: QuotationModule;
|
|
22
24
|
}
|
|
23
25
|
export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
24
26
|
protected defaultName: string;
|
|
@@ -26,6 +28,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
26
28
|
isSolution: boolean;
|
|
27
29
|
protected initializeOptions: ModuleOptions;
|
|
28
30
|
private logger;
|
|
31
|
+
private appPlugin;
|
|
29
32
|
protected store: BaseSalesState;
|
|
30
33
|
protected otherParams: Record<string, any>;
|
|
31
34
|
protected cacheId: string | undefined;
|
|
@@ -39,7 +42,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
39
42
|
constructor(name?: string, version?: string);
|
|
40
43
|
/**
|
|
41
44
|
* 子类可覆盖此方法以追加/收敛要注册的子模块。
|
|
42
|
-
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment。
|
|
45
|
+
* 默认包含通用销售模块:products / order / salesSummary / schedule / payment / quotation。
|
|
43
46
|
*/
|
|
44
47
|
protected getRegisteredModuleNames(): readonly string[];
|
|
45
48
|
/**
|
|
@@ -55,6 +58,10 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
55
58
|
*/
|
|
56
59
|
private logError;
|
|
57
60
|
get payment(): PaymentModule | undefined;
|
|
61
|
+
private getCurrentOrderCustomerId;
|
|
62
|
+
private applyQuotationScheduleResolver;
|
|
63
|
+
private loadQuotationForPriceQuery;
|
|
64
|
+
protected getSubmitOrderSalesChannel(): string | undefined;
|
|
58
65
|
/**
|
|
59
66
|
* 工厂入口:根据子模块名实例化对应模块。
|
|
60
67
|
* 默认使用 BookingByStep 公共 `createModule`。子类若需引入额外类型(如 customer),
|
|
@@ -67,6 +74,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
67
74
|
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
68
75
|
*/
|
|
69
76
|
protected readSessionCacheData(): Record<string, any>;
|
|
77
|
+
private getAppData;
|
|
78
|
+
private syncAppDataToTempOrder;
|
|
70
79
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
71
80
|
destroy(): Promise<void>;
|
|
72
81
|
/**
|
|
@@ -91,27 +100,54 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
91
100
|
getPayments(): ISalesPayment[];
|
|
92
101
|
/** 获取附加费用(运费/服务费/税费等)。 */
|
|
93
102
|
getSurcharges(): ISalesSurcharge[];
|
|
94
|
-
getTempOrder():
|
|
103
|
+
getTempOrder(): OrderTempOrder | null;
|
|
104
|
+
replaceTempOrder(tempOrder: OrderTempOrder): Promise<OrderTempOrder>;
|
|
95
105
|
getOrderIdentity(): import("../../modules/Order/types").OrderIdentitySnapshot | null;
|
|
96
106
|
getOrderSnapshot(): import("../../modules/Order/types").OrderSnapshot | null;
|
|
97
107
|
getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
|
|
98
108
|
getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
|
|
99
109
|
getTempOrderNote(): string;
|
|
100
110
|
updateTempOrderNote(note: string): string;
|
|
111
|
+
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
112
|
+
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
113
|
+
updateRemoteOrderNote(orderId: number | string, note: string): void;
|
|
101
114
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
102
115
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
103
116
|
private ensureTempOrder;
|
|
104
|
-
addNewOrder(): Promise<
|
|
117
|
+
addNewOrder(): Promise<OrderTempOrder>;
|
|
105
118
|
saveDraft(): Promise<void>;
|
|
106
|
-
restoreOrder(): Promise<
|
|
119
|
+
restoreOrder(): Promise<OrderTempOrder>;
|
|
120
|
+
/**
|
|
121
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
122
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
123
|
+
*/
|
|
124
|
+
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
107
125
|
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
108
126
|
getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
|
|
127
|
+
private getHistoricalProductDiscountList;
|
|
128
|
+
private isPersistedOrderProduct;
|
|
129
|
+
private mergeHistoricalDiscountList;
|
|
130
|
+
loadDiscountConfig(params?: {
|
|
131
|
+
customerId?: number;
|
|
132
|
+
action?: 'create' | 'edit';
|
|
133
|
+
}): Promise<{
|
|
134
|
+
productList: Record<string, any>[];
|
|
135
|
+
discountList: Discount[];
|
|
136
|
+
}>;
|
|
137
|
+
bestDiscount(cb?: (result: any) => void): Promise<{
|
|
138
|
+
productList: Record<string, any>[];
|
|
139
|
+
discountList: Discount[];
|
|
140
|
+
}>;
|
|
109
141
|
getDiscountList(): Discount[];
|
|
110
142
|
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
111
143
|
setDiscountSelected(params: {
|
|
112
144
|
discountId: number;
|
|
113
145
|
isSelected: boolean;
|
|
114
146
|
}): Promise<void>;
|
|
147
|
+
applyDiscountCalculationResult(result?: {
|
|
148
|
+
productList?: Record<string, any>[];
|
|
149
|
+
discountList?: Discount[];
|
|
150
|
+
}): Promise<void>;
|
|
115
151
|
submitScanOrder<T = any>(params?: {
|
|
116
152
|
payments?: OrderPaymentSource[];
|
|
117
153
|
paymentStatus?: BaseSalesPaymentStatus;
|
|
@@ -183,8 +219,11 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
183
219
|
submitBeforeSend?: boolean;
|
|
184
220
|
}): Promise<T>;
|
|
185
221
|
transformBaseProductToOrderProduct(params: TransformBaseProductToOrderProductParams): import("./utils/transformBaseProductToOrderProduct").BaseProductOrderProductInput | null;
|
|
222
|
+
calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
|
|
186
223
|
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
187
|
-
|
|
224
|
+
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
225
|
+
updateOrderProductQuantity(params: BaseSalesUpdateOrderProductQuantityParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
226
|
+
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
188
227
|
/**
|
|
189
228
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|
|
190
229
|
* 多行同 SKU 时必须传入与删除/更新一致的 unique_identification_number。
|