@pisell/pisellos 2.2.167 → 2.2.169
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/buildCacheItemFromOrderLine.js +51 -15
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +26 -2
- package/dist/modules/Customer/index.d.ts +6 -0
- package/dist/modules/Customer/index.js +122 -77
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +5 -10
- package/dist/modules/Order/index.js +53 -9
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +25 -10
- package/dist/modules/Rules/index.d.ts +4 -0
- package/dist/modules/Rules/index.js +26 -10
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/solution/BaseSales/index.js +11 -5
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +37 -6
- package/dist/solution/BaseSales/utils.js +11 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +9 -0
- package/dist/solution/BookingTicket/index.js +372 -192
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
- package/dist/solution/ScanOrder/utils.js +11 -2
- package/dist/solution/VenueBooking/index.d.ts +1 -6
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +42 -9
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +22 -1
- package/lib/modules/Customer/index.d.ts +6 -0
- package/lib/modules/Customer/index.js +18 -3
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +5 -10
- package/lib/modules/Order/index.js +52 -5
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +46 -10
- package/lib/modules/Rules/index.d.ts +4 -0
- package/lib/modules/Rules/index.js +22 -14
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/solution/BaseSales/index.js +6 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +42 -4
- package/lib/solution/BaseSales/utils.js +10 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +9 -0
- package/lib/solution/BookingTicket/index.js +78 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -1
- package/lib/solution/ScanOrder/utils.js +10 -2
- package/lib/solution/VenueBooking/index.d.ts +1 -6
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ __export(utils_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(utils_exports);
|
|
39
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
40
|
var import_utils = require("../../modules/Order/utils");
|
|
41
|
+
var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
41
42
|
function createEmptySummary() {
|
|
42
43
|
return {
|
|
43
44
|
product_quantity: 0,
|
|
@@ -203,9 +204,16 @@ function normalizeOrderProduct(product) {
|
|
|
203
204
|
useOriginalBundle: true
|
|
204
205
|
});
|
|
205
206
|
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
206
|
-
{ num: product.num, metadata },
|
|
207
|
+
{ num: product.num, metadata, lineOriginalPrice: product.original_price },
|
|
207
208
|
composedOriginalPrice
|
|
208
209
|
);
|
|
210
|
+
const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
|
|
211
|
+
discountList: product.discount_list,
|
|
212
|
+
metadata,
|
|
213
|
+
originalPrice: finalOriginalPrice,
|
|
214
|
+
sellingPrice: composedSellingPrice,
|
|
215
|
+
quantity: getSafeProductNum(product.num)
|
|
216
|
+
});
|
|
209
217
|
return {
|
|
210
218
|
order_detail_id: product.order_detail_id || null,
|
|
211
219
|
product_id: product.product_id,
|
|
@@ -216,7 +224,7 @@ function normalizeOrderProduct(product) {
|
|
|
216
224
|
original_price: finalOriginalPrice,
|
|
217
225
|
tax_fee: product.tax_fee || "0.00",
|
|
218
226
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
219
|
-
discount_list:
|
|
227
|
+
discount_list: discountList,
|
|
220
228
|
product_bundle: normalizedBundle,
|
|
221
229
|
metadata,
|
|
222
230
|
note: product.note != null ? String(product.note) : ""
|
|
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
311
311
|
date: string;
|
|
312
312
|
status: string;
|
|
313
313
|
week: string;
|
|
314
|
-
weekNum: 0 |
|
|
314
|
+
weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
|
|
315
315
|
}[]>;
|
|
316
316
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
317
317
|
private getScheduleDataByIds;
|
|
@@ -4,6 +4,7 @@ import type { ProductData } from '../../modules';
|
|
|
4
4
|
import { type BookingContextConfig, type BookingContextDateInput, type BookingContextResource, type BookingContextResourceMap, type BookingContextState, type InitBookingContextParams, type LoadBookingConfigParams, type LoadBookingResourcesParams, type ResourceError, type BookingCalcContext } from '../../modules/BookingContext';
|
|
5
5
|
import type { OrderCustomerView } from '../../modules/Order/types';
|
|
6
6
|
import { BaseSalesImpl } from '../BaseSales';
|
|
7
|
+
import type { BaseSalesScanCodeResult } from '../BaseSales/types';
|
|
7
8
|
import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
|
|
8
9
|
import type { LoadSalesDetailParams } from '../../modules/Order/types';
|
|
9
10
|
import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
|
|
@@ -43,6 +44,14 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
43
44
|
* 让现有 setActiveCustomer / getActiveCustomer 调用方零成本拿到详情态客户。
|
|
44
45
|
*/
|
|
45
46
|
loadSalesDetail(orderIdOrParams: number | string | LoadSalesDetailParams): Promise<ISalesDetail>;
|
|
47
|
+
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
48
|
+
private hydrateOrderCustomerFromScanDiscounts;
|
|
49
|
+
private getDiscountCustomerId;
|
|
50
|
+
private resolveCustomerByDiscountCustomerId;
|
|
51
|
+
private findCustomerById;
|
|
52
|
+
private normalizeCustomer;
|
|
53
|
+
private getRawCustomerId;
|
|
54
|
+
private hasUsableCustomerDetails;
|
|
46
55
|
/**
|
|
47
56
|
* 更新当前预约的 appointment_status。
|
|
48
57
|
*
|
|
@@ -133,6 +133,83 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
133
133
|
}
|
|
134
134
|
return sales;
|
|
135
135
|
}
|
|
136
|
+
async scanPromotionCode(code, customerId) {
|
|
137
|
+
if (!this.store.order)
|
|
138
|
+
throw new Error("order 模块未初始化");
|
|
139
|
+
const raw = await this.store.order.scanCode(code, customerId);
|
|
140
|
+
if (raw.isAvailable) {
|
|
141
|
+
await this.hydrateOrderCustomerFromScanDiscounts(raw.scannedDiscountList);
|
|
142
|
+
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
143
|
+
this.store.order.persistTempOrder();
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
isAvailable: raw.isAvailable,
|
|
147
|
+
type: raw.type,
|
|
148
|
+
unavailableReason: raw.unavailableReason
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
async hydrateOrderCustomerFromScanDiscounts(discounts) {
|
|
152
|
+
const currentOrderCustomer = this.store.order.getOrderCustomer();
|
|
153
|
+
if (currentOrderCustomer)
|
|
154
|
+
return;
|
|
155
|
+
const customerId = this.getDiscountCustomerId(discounts);
|
|
156
|
+
if (!customerId)
|
|
157
|
+
return;
|
|
158
|
+
const customer = await this.resolveCustomerByDiscountCustomerId(customerId);
|
|
159
|
+
if (!customer)
|
|
160
|
+
return;
|
|
161
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
162
|
+
this.setOrderCustomer(customer);
|
|
163
|
+
}
|
|
164
|
+
getDiscountCustomerId(discounts) {
|
|
165
|
+
const discount = discounts.find((item) => item.customer_id != null);
|
|
166
|
+
const customerId = Number(discount == null ? void 0 : discount.customer_id);
|
|
167
|
+
if (!Number.isFinite(customerId) || customerId <= 0)
|
|
168
|
+
return null;
|
|
169
|
+
return customerId;
|
|
170
|
+
}
|
|
171
|
+
async resolveCustomerByDiscountCustomerId(customerId) {
|
|
172
|
+
var _a;
|
|
173
|
+
const localCustomers = this.store.customer.getCustomers();
|
|
174
|
+
const localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
175
|
+
const normalizedLocalCustomer = localCustomer ? this.normalizeCustomer(localCustomer) : null;
|
|
176
|
+
if (normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer)) {
|
|
177
|
+
return normalizedLocalCustomer;
|
|
178
|
+
}
|
|
179
|
+
const result = await this.store.customer.queryCustomerList({
|
|
180
|
+
ids: [customerId],
|
|
181
|
+
skip: 1,
|
|
182
|
+
num: 1
|
|
183
|
+
});
|
|
184
|
+
const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
|
|
185
|
+
return remoteCustomer ? this.normalizeCustomer(remoteCustomer) : null;
|
|
186
|
+
}
|
|
187
|
+
findCustomerById(customers = [], customerId) {
|
|
188
|
+
return customers.find((customer) => {
|
|
189
|
+
const rawId = this.getRawCustomerId(customer);
|
|
190
|
+
return rawId !== null && String(rawId) === String(customerId);
|
|
191
|
+
}) || null;
|
|
192
|
+
}
|
|
193
|
+
normalizeCustomer(customer) {
|
|
194
|
+
const raw = customer;
|
|
195
|
+
const rawId = this.getRawCustomerId(customer);
|
|
196
|
+
const name = customer.name || raw.display_name || raw.nickname || raw.customer_name || [raw.first_name, raw.last_name].filter(Boolean).join(" ") || "";
|
|
197
|
+
return {
|
|
198
|
+
...customer,
|
|
199
|
+
id: rawId ?? customer.id,
|
|
200
|
+
name,
|
|
201
|
+
phone: customer.phone ?? raw.phone ?? raw.mobile ?? "",
|
|
202
|
+
email: customer.email ?? raw.email ?? "",
|
|
203
|
+
country_calling_code: customer.country_calling_code ?? raw.country_calling_code ?? ""
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
getRawCustomerId(customer) {
|
|
207
|
+
const raw = customer;
|
|
208
|
+
return customer.id ?? raw.customer_id ?? raw.customerId ?? null;
|
|
209
|
+
}
|
|
210
|
+
hasUsableCustomerDetails(customer) {
|
|
211
|
+
return !!(customer.name || customer.phone || customer.email || customer.display_name || customer.customer_name);
|
|
212
|
+
}
|
|
136
213
|
/**
|
|
137
214
|
* 更新当前预约的 appointment_status。
|
|
138
215
|
*
|
|
@@ -213,7 +290,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
213
290
|
*/
|
|
214
291
|
async loadProducts(params = {}, options) {
|
|
215
292
|
const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
|
|
216
|
-
const bookingDate =
|
|
293
|
+
const bookingDate = schedule_datetime || schedule_date || "";
|
|
217
294
|
if (bookingDate) {
|
|
218
295
|
this.setBookingDate(bookingDate);
|
|
219
296
|
}
|
|
@@ -184,7 +184,7 @@ function buildRequiresDetailPayload(item, ctx) {
|
|
|
184
184
|
number: Boolean(item == null ? void 0 : item.open_sold_weight)
|
|
185
185
|
},
|
|
186
186
|
isOnlySession,
|
|
187
|
-
isEject,
|
|
187
|
+
isEject: isEject ? 1 : 0,
|
|
188
188
|
customerId: ctx == null ? void 0 : ctx.customerId,
|
|
189
189
|
date: formatBookingDateForUI(ctx == null ? void 0 : ctx.date),
|
|
190
190
|
productData: item
|
|
@@ -298,6 +298,8 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
|
|
|
298
298
|
origin_total: extend == null ? void 0 : extend.origin_total,
|
|
299
299
|
price_override: extend == null ? void 0 : extend.priceOverride,
|
|
300
300
|
bundle_edit: extend == null ? void 0 : extend.bundle_edit,
|
|
301
|
+
discount_reason: extend == null ? void 0 : extend.discount_reason,
|
|
302
|
+
discount_list: cacheItem == null ? void 0 : cacheItem.discount_list,
|
|
301
303
|
_extend: extend
|
|
302
304
|
};
|
|
303
305
|
}
|
|
@@ -63,6 +63,7 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
63
63
|
var import_dayjs = __toESM(require("dayjs"));
|
|
64
64
|
var import_decimal = __toESM(require("decimal.js"));
|
|
65
65
|
var import_utils = require("../../modules/Order/utils");
|
|
66
|
+
var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
|
|
66
67
|
function createEmptySummary() {
|
|
67
68
|
return {
|
|
68
69
|
product_quantity: 0,
|
|
@@ -507,9 +508,16 @@ function normalizeOrderProduct(product) {
|
|
|
507
508
|
useOriginalBundle: true
|
|
508
509
|
});
|
|
509
510
|
const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
|
|
510
|
-
{ num: product.num, metadata },
|
|
511
|
+
{ num: product.num, metadata, lineOriginalPrice: product.original_price },
|
|
511
512
|
composedOriginalPrice
|
|
512
513
|
);
|
|
514
|
+
const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
|
|
515
|
+
discountList: product.discount_list,
|
|
516
|
+
metadata,
|
|
517
|
+
originalPrice: finalOriginalPrice,
|
|
518
|
+
sellingPrice: composedSellingPrice,
|
|
519
|
+
quantity: getSafeProductNum(product.num)
|
|
520
|
+
});
|
|
513
521
|
return {
|
|
514
522
|
order_detail_id: product.order_detail_id || null,
|
|
515
523
|
product_id: product.product_id,
|
|
@@ -520,7 +528,7 @@ function normalizeOrderProduct(product) {
|
|
|
520
528
|
original_price: finalOriginalPrice,
|
|
521
529
|
tax_fee: product.tax_fee || "0.00",
|
|
522
530
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
523
|
-
discount_list:
|
|
531
|
+
discount_list: discountList,
|
|
524
532
|
product_bundle: normalizedBundle,
|
|
525
533
|
metadata,
|
|
526
534
|
note: product.note != null ? String(product.note) : ""
|
|
@@ -150,12 +150,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
150
150
|
customerId: number;
|
|
151
151
|
}): Promise<void>;
|
|
152
152
|
private recalculateOrderPricesFromQuotation;
|
|
153
|
-
scanCode(code: string, customerId?: number): Promise<
|
|
154
|
-
isAvailable: boolean;
|
|
155
|
-
discountList: import("../../modules/Discount").Discount[];
|
|
156
|
-
type: "server" | "clientCalc";
|
|
157
|
-
unavailableReason?: import("../../modules/Rules/types").UnavailableReason | undefined;
|
|
158
|
-
}>;
|
|
153
|
+
scanCode(code: string, customerId?: number): Promise<import("../../modules/Order/types").OrderScanCodeResult>;
|
|
159
154
|
/** 获取当前折扣列表(包装 order.getDiscountList) */
|
|
160
155
|
getDiscountList(): import("../../modules/Discount").Discount[];
|
|
161
156
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|