@pisell/pisellos 0.10.7 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +12 -5
- package/dist/modules/Order/index.js +310 -210
- package/dist/modules/Order/types.d.ts +26 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +810 -729
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +9 -2
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +15 -5
- package/dist/solution/BaseSales/index.js +211 -159
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -4
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +12 -5
- package/lib/modules/Order/index.js +148 -43
- package/lib/modules/Order/types.d.ts +26 -3
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +51 -0
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +9 -3
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +15 -5
- package/lib/solution/BaseSales/index.js +64 -16
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -4
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -134,9 +134,11 @@ function resolveMainProductPrice(product, fallback) {
|
|
|
134
134
|
}
|
|
135
135
|
function mapOrderBundleToOtherBundle(bundle) {
|
|
136
136
|
return bundle.map(function (item) {
|
|
137
|
-
var _ref7, _item$original_price;
|
|
137
|
+
var _ref7, _ref8, _item$original_price;
|
|
138
138
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
139
|
-
|
|
139
|
+
// 后端历史订单可能没有 original_price;此时 price 是折前毛价,
|
|
140
|
+
// bundle_selling_price 已包含折扣,不能把它当成编辑时的新原价。
|
|
141
|
+
original_price: (_ref7 = (_ref8 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.product_price) !== null && _ref8 !== void 0 ? _ref8 : item.price) !== null && _ref7 !== void 0 ? _ref7 : item.bundle_selling_price
|
|
140
142
|
});
|
|
141
143
|
});
|
|
142
144
|
}
|
|
@@ -167,10 +169,10 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
167
169
|
});
|
|
168
170
|
if (relationIdsByForm.size === 0) return undefined;
|
|
169
171
|
return {
|
|
170
|
-
resources: Array.from(relationIdsByForm.entries()).map(function (
|
|
171
|
-
var
|
|
172
|
-
formId =
|
|
173
|
-
relationIds =
|
|
172
|
+
resources: Array.from(relationIdsByForm.entries()).map(function (_ref9) {
|
|
173
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
174
|
+
formId = _ref10[0],
|
|
175
|
+
relationIds = _ref10[1];
|
|
174
176
|
return {
|
|
175
177
|
id: formId,
|
|
176
178
|
status: 1,
|
|
@@ -190,7 +192,7 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
190
192
|
* 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
|
|
191
193
|
*/
|
|
192
194
|
export function buildCacheItemFromOrderLine(input) {
|
|
193
|
-
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num,
|
|
195
|
+
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref11, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref12, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref13, _booking$id;
|
|
194
196
|
var product = input.product,
|
|
195
197
|
booking = input.booking,
|
|
196
198
|
sourceProduct = input.sourceProduct;
|
|
@@ -225,7 +227,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
225
227
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
|
|
226
228
|
product_name: productTitle,
|
|
227
229
|
product_cover: productCover,
|
|
228
|
-
note: (
|
|
230
|
+
note: (_ref11 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref11 !== void 0 ? _ref11 : '',
|
|
229
231
|
price: mainProductPrice,
|
|
230
232
|
total: selling,
|
|
231
233
|
origin_total: original,
|
|
@@ -260,7 +262,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
260
262
|
var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
261
263
|
id: resolvedId,
|
|
262
264
|
product_id: resolvedId,
|
|
263
|
-
extension_type: (
|
|
265
|
+
extension_type: (_ref12 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref12 !== void 0 ? _ref12 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
|
|
264
266
|
title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
|
|
265
267
|
price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
|
|
266
268
|
selling_price: product.selling_price,
|
|
@@ -274,7 +276,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
274
276
|
new: 0,
|
|
275
277
|
autoClose: false,
|
|
276
278
|
order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
|
|
277
|
-
booking_id: (
|
|
279
|
+
booking_id: (_ref13 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref13 !== void 0 ? _ref13 : 0
|
|
278
280
|
});
|
|
279
281
|
if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
|
|
280
282
|
base.capacity = sourceProduct.capacity;
|
|
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions } from './types';
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
9
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -156,6 +156,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
156
156
|
* sessionStorage 的 cacheId 分桶。写入失败由 BaseModule 静默降级。
|
|
157
157
|
*/
|
|
158
158
|
persistTempOrder(): void;
|
|
159
|
+
/**
|
|
160
|
+
* 终止当前模块实例的 sessionStorage 订单恢复会话。
|
|
161
|
+
*
|
|
162
|
+
* 支付跳转等终态场景需要同时删除当前 cacheId 的 tempOrder 快照,并关闭
|
|
163
|
+
* 本实例后续异步任务的再次写入;新模块实例初始化时会按 otherParams 重新启用。
|
|
164
|
+
*/
|
|
165
|
+
clearSessionStoragePersistedTempOrder(): void;
|
|
159
166
|
consumeSessionStorageRestore(): Record<string, any> | null;
|
|
160
167
|
notifyTempOrderChanged(): void;
|
|
161
168
|
private createDefaultTempOrderInstance;
|
|
@@ -396,7 +403,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
396
403
|
* await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
|
|
397
404
|
* // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
|
|
398
405
|
*/
|
|
399
|
-
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput): Promise<OrderProduct[]>;
|
|
406
|
+
addProductToOrder(product: Partial<OrderProduct> & OrderProductIdentity, booking?: AddProductBookingInput, options?: AddProductToOrderOptions): Promise<OrderProduct[]>;
|
|
400
407
|
/**
|
|
401
408
|
* 批量添加商品行,所有行追加完成后只触发一次促销、折扣、summary 重算与持久化。
|
|
402
409
|
*
|
|
@@ -434,8 +441,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
434
441
|
* @example
|
|
435
442
|
* await order.removeProductsFromOrder([identityA, identityB]);
|
|
436
443
|
*/
|
|
437
|
-
removeProductsFromOrder(identities: OrderProductIdentity[]): Promise<OrderProduct[]>;
|
|
438
|
-
removeProductFromOrder(identity: OrderProductIdentity): Promise<OrderProduct[]>;
|
|
444
|
+
removeProductsFromOrder(identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
445
|
+
removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
439
446
|
/**
|
|
440
447
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
441
448
|
* 用于「仅清空商品」;客户、备注、支付等协议字段保持不变。
|
|
@@ -575,4 +582,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
575
582
|
getOrderInfo(order_id: number): Promise<any>;
|
|
576
583
|
getVouchers(): any[];
|
|
577
584
|
}
|
|
578
|
-
export type { UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
585
|
+
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|