@pisell/pisellos 2.2.164 → 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/utils/buildNormalProductCacheItemFromOrderLine.js +45 -15
- package/dist/modules/Order/index.d.ts +10 -3
- package/dist/modules/Order/index.js +272 -142
- package/dist/modules/Order/types.d.ts +14 -2
- package/dist/modules/Order/types.js +2 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +67 -15
- package/dist/server/index.js +1 -0
- package/dist/solution/BaseSales/index.d.ts +9 -1
- package/dist/solution/BaseSales/index.js +369 -240
- package/dist/solution/BaseSales/types.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +33 -14
- package/dist/solution/BaseSales/utils.js +36 -7
- package/dist/solution/BookingTicket/index.d.ts +3 -0
- package/dist/solution/BookingTicket/index.js +155 -86
- package/dist/solution/BookingTicket/utils/addProductDecision.js +19 -11
- package/dist/solution/ScanOrder/utils.js +36 -7
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +35 -9
- package/lib/modules/Order/index.d.ts +10 -3
- package/lib/modules/Order/index.js +104 -4
- package/lib/modules/Order/types.d.ts +14 -2
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +58 -9
- package/lib/server/index.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +9 -1
- package/lib/solution/BaseSales/index.js +65 -3
- package/lib/solution/BaseSales/types.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +31 -10
- package/lib/solution/BaseSales/utils.js +37 -5
- package/lib/solution/BookingTicket/index.d.ts +3 -0
- package/lib/solution/BookingTicket/index.js +48 -6
- package/lib/solution/BookingTicket/utils/addProductDecision.js +16 -8
- package/lib/solution/ScanOrder/utils.js +37 -5
- package/package.json +1 -1
|
@@ -107,7 +107,7 @@ export interface OrderTempOrder {
|
|
|
107
107
|
shop_order_number: string | null;
|
|
108
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;
|
|
@@ -193,6 +193,11 @@ export interface UpdateOrderProductParams {
|
|
|
193
193
|
product_bundle?: any[];
|
|
194
194
|
booking?: AddProductBookingInput;
|
|
195
195
|
}
|
|
196
|
+
/** 仅更新购物车行数量;行定位语义与 updateOrderProduct / removeProductFromOrder 保持一致 */
|
|
197
|
+
export interface UpdateOrderProductQuantityParams extends OrderProductIdentity {
|
|
198
|
+
num: number;
|
|
199
|
+
identity_key?: string;
|
|
200
|
+
}
|
|
196
201
|
export interface UpdateOrderBookingParams {
|
|
197
202
|
unique_identification_number: string;
|
|
198
203
|
updates: AddProductBookingInput;
|
|
@@ -251,7 +256,7 @@ export interface SubmitSalesOrderParams {
|
|
|
251
256
|
shop_order_number: string | null;
|
|
252
257
|
shop_full_order_number: string | null;
|
|
253
258
|
type: string;
|
|
254
|
-
business_code
|
|
259
|
+
business_code?: string;
|
|
255
260
|
platform: string;
|
|
256
261
|
request_unique_idempotency_token?: string;
|
|
257
262
|
sales_channel: string;
|
|
@@ -362,6 +367,7 @@ export interface SyncPaymentsToOrderParams {
|
|
|
362
367
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
363
368
|
submitWhenPaid?: boolean;
|
|
364
369
|
smallTicketDataFlag?: number;
|
|
370
|
+
channel?: string;
|
|
365
371
|
}
|
|
366
372
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
367
373
|
isFullyPaid: boolean;
|
|
@@ -482,8 +488,14 @@ export interface OrderModuleAPI {
|
|
|
482
488
|
updateTempOrderContactsInfo: (contactsInfo: Record<string, any> | null) => Record<string, any> | null;
|
|
483
489
|
addProductToOrder: (product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput) => Promise<OrderProduct[]>;
|
|
484
490
|
updateOrderProduct: (params: UpdateOrderProductParams) => Promise<OrderProduct[]>;
|
|
491
|
+
updateOrderProductQuantity: (params: UpdateOrderProductQuantityParams) => Promise<OrderProduct[]>;
|
|
485
492
|
updateOrderBooking: (params: UpdateOrderBookingParams) => any[];
|
|
486
493
|
removeProductFromOrder: (identity: OrderProductIdentity) => Promise<OrderProduct[]>;
|
|
494
|
+
/**
|
|
495
|
+
* 仅清空购物车行:products / bookings / discount_list(保留客户、备注、支付等其它 tempOrder 字段)。
|
|
496
|
+
* 内部会 applyDiscount + recalculateSummary + persist。
|
|
497
|
+
*/
|
|
498
|
+
clearOrderCartLines: () => Promise<OrderTempOrder>;
|
|
487
499
|
persistTempOrder: () => void;
|
|
488
500
|
submitTempOrder: <T = any>(params?: {
|
|
489
501
|
cacheId?: string;
|
|
@@ -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 类商品的开始时间结束时间生成商品的时长
|
|
@@ -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,
|
|
@@ -505,8 +547,8 @@ export function createDefaultTempOrder(params) {
|
|
|
505
547
|
order_number: null,
|
|
506
548
|
shop_order_number: null,
|
|
507
549
|
shop_full_order_number: null,
|
|
508
|
-
type: '
|
|
509
|
-
business_code:
|
|
550
|
+
type: '',
|
|
551
|
+
business_code: undefined,
|
|
510
552
|
platform: 'h5',
|
|
511
553
|
sales_channel: 'my_pisel',
|
|
512
554
|
order_sales_channel: 'online_store',
|
|
@@ -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,
|
|
@@ -579,16 +621,26 @@ export function buildSubmitPayload(params) {
|
|
|
579
621
|
_createDate = _ref9.create_date,
|
|
580
622
|
_holderId = _ref9.holder_id,
|
|
581
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
|
+
}
|
|
582
634
|
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
583
635
|
order_number: null,
|
|
584
636
|
shop_order_number: null,
|
|
585
637
|
shop_full_order_number: null,
|
|
586
638
|
platform: normalizeSubmitPlatform(platform),
|
|
587
639
|
request_unique_idempotency_token: tempOrder.request_unique_idempotency_token || "".concat(tempOrder.external_sale_number, "_").concat(now.getTime()),
|
|
588
|
-
type:
|
|
589
|
-
business_code:
|
|
640
|
+
type: submitType,
|
|
641
|
+
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
590
642
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
591
|
-
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',
|
|
592
644
|
status: tempOrder.status || 'normal',
|
|
593
645
|
payment_status: tempOrder.payment_status || 'payment_processing',
|
|
594
646
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
@@ -615,10 +667,10 @@ export function buildSubmitPayload(params) {
|
|
|
615
667
|
// holder: tempOrder.holder || null,
|
|
616
668
|
// summary,
|
|
617
669
|
metadata: function () {
|
|
618
|
-
var
|
|
619
|
-
_collectPax =
|
|
620
|
-
_tableOccupancyDuration =
|
|
621
|
-
rest = _objectWithoutProperties(
|
|
670
|
+
var _ref11 = tempOrder.metadata || {},
|
|
671
|
+
_collectPax = _ref11.collect_pax,
|
|
672
|
+
_tableOccupancyDuration = _ref11.table_occupancy_duration,
|
|
673
|
+
rest = _objectWithoutProperties(_ref11, _excluded4);
|
|
622
674
|
return _objectSpread({}, rest);
|
|
623
675
|
}(),
|
|
624
676
|
products: (tempOrder.products || []).map(function (product) {
|
package/dist/server/index.js
CHANGED
|
@@ -2995,6 +2995,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
2995
2995
|
if (field === undefined || field === null || field === '') return;
|
|
2996
2996
|
searchParams.append('with[]', String(field));
|
|
2997
2997
|
});
|
|
2998
|
+
searchParams.append('lookup_mode', 'multi');
|
|
2998
2999
|
var query = searchParams.toString();
|
|
2999
3000
|
return "/shop/order/sales/".concat(encodeURIComponent(orderId)).concat(query ? "?".concat(query) : '');
|
|
3000
3001
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
-
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
|
|
3
|
+
import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesScanCodeResult } from './types';
|
|
4
4
|
import { OrderModule } from '../../modules/Order';
|
|
5
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';
|
|
@@ -110,15 +110,22 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
110
110
|
updateTempOrderNote(note: string): string;
|
|
111
111
|
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
112
112
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
113
|
+
updateRemoteOrderNote(orderId: number | string, note: string): void;
|
|
113
114
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
114
115
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
115
116
|
private ensureTempOrder;
|
|
116
117
|
addNewOrder(): Promise<OrderTempOrder>;
|
|
117
118
|
saveDraft(): Promise<void>;
|
|
118
119
|
restoreOrder(): Promise<OrderTempOrder>;
|
|
120
|
+
/**
|
|
121
|
+
* 仅清空 tempOrder 购物车行(products / bookings / discount_list)。
|
|
122
|
+
* 同步清空内存中的 salesDetail 商品/预约视图,避免编辑态仍读到旧 bookings。
|
|
123
|
+
*/
|
|
124
|
+
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
119
125
|
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
120
126
|
getSummary(): Promise<import("../../modules/Order/types").OrderSummary>;
|
|
121
127
|
private getHistoricalProductDiscountList;
|
|
128
|
+
private isPersistedOrderProduct;
|
|
122
129
|
private mergeHistoricalDiscountList;
|
|
123
130
|
loadDiscountConfig(params?: {
|
|
124
131
|
customerId?: number;
|
|
@@ -215,6 +222,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
215
222
|
calculateProductBookingPrice(params: BaseSalesCalculateProductBookingPriceParams): Promise<BaseSalesProductBookingPriceResult>;
|
|
216
223
|
addProductToOrder(product: Partial<BaseSalesOrderProduct> & BaseSalesOrderProductIdentity, booking?: AddProductBookingInput): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
217
224
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
225
|
+
updateOrderProductQuantity(params: BaseSalesUpdateOrderProductQuantityParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
218
226
|
updateOrderBooking(params: UpdateOrderBookingParams): any[];
|
|
219
227
|
/**
|
|
220
228
|
* 设置单行商品备注(与整单 `updateTempOrderNote` 区分)。
|