@pisell/pisellos 2.2.153 → 2.2.154
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/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Cart/utils/cartProduct.js +1 -1
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +231 -160
- package/dist/modules/Order/types.d.ts +19 -0
- package/dist/modules/Order/utils.js +7 -6
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +567 -505
- package/dist/modules/Payment/types.d.ts +29 -9
- package/dist/modules/SalesSummary/index.d.ts +7 -5
- package/dist/modules/SalesSummary/index.js +35 -11
- package/dist/plugins/app.d.ts +2 -0
- package/dist/server/index.d.ts +2 -5
- package/dist/server/index.js +58 -66
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/products/index.d.ts +12 -1
- package/dist/server/modules/products/index.js +169 -78
- package/dist/server/modules/products/types.d.ts +11 -0
- package/dist/server/modules/products/types.js +4 -0
- package/dist/server/utils/product.js +2 -2
- package/dist/solution/BaseSales/index.d.ts +26 -2
- package/dist/solution/BaseSales/index.js +342 -112
- package/dist/solution/BaseSales/types.d.ts +4 -4
- package/dist/solution/BaseSales/types.js +4 -4
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
- package/dist/solution/BaseSales/utils.js +3 -3
- package/dist/solution/BookingTicket/index.d.ts +11 -13
- package/dist/solution/BookingTicket/index.js +23 -37
- package/dist/solution/BookingTicket/types.d.ts +9 -6
- package/dist/solution/BookingTicket/types.js +6 -3
- package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/dist/solution/BookingTicket/utils/cartView.js +52 -14
- package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
- package/dist/solution/Sales/index.d.ts +3 -0
- package/dist/solution/Sales/index.js +85 -43
- package/dist/solution/Sales/types.d.ts +3 -0
- package/dist/solution/ScanOrder/types.d.ts +4 -4
- package/dist/solution/ScanOrder/types.js +4 -4
- package/dist/solution/ScanOrder/utils.js +3 -3
- package/lib/core/index.js +1 -0
- package/lib/modules/Cart/utils/cartProduct.js +1 -1
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +39 -7
- package/lib/modules/Order/types.d.ts +19 -0
- package/lib/modules/Order/utils.js +4 -2
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +26 -2
- package/lib/modules/Payment/types.d.ts +29 -9
- package/lib/modules/SalesSummary/index.d.ts +7 -5
- package/lib/modules/SalesSummary/index.js +29 -9
- package/lib/plugins/app.d.ts +2 -0
- package/lib/server/index.d.ts +2 -5
- package/lib/server/index.js +38 -58
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/products/index.d.ts +12 -1
- package/lib/server/modules/products/index.js +69 -9
- package/lib/server/modules/products/types.d.ts +11 -0
- package/lib/server/utils/product.js +2 -2
- package/lib/solution/BaseSales/index.d.ts +26 -2
- package/lib/solution/BaseSales/index.js +169 -3
- package/lib/solution/BaseSales/types.d.ts +4 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
- package/lib/solution/BaseSales/utils.js +3 -3
- package/lib/solution/BookingTicket/index.d.ts +11 -13
- package/lib/solution/BookingTicket/index.js +17 -27
- package/lib/solution/BookingTicket/types.d.ts +9 -6
- package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
- package/lib/solution/BookingTicket/utils/cartView.js +44 -18
- package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
- package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
- package/lib/solution/Sales/index.d.ts +3 -0
- package/lib/solution/Sales/index.js +50 -15
- package/lib/solution/Sales/types.d.ts +3 -0
- package/lib/solution/ScanOrder/types.d.ts +4 -4
- package/lib/solution/ScanOrder/utils.js +3 -3
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(BookingTicket_exports);
|
|
|
37
37
|
var import_types = require("./types");
|
|
38
38
|
var import_BaseSales = require("../BaseSales");
|
|
39
39
|
var import_scan = __toESM(require("./utils/scan"));
|
|
40
|
+
var import_orderCustomer = require("./utils/orderCustomer");
|
|
40
41
|
var import_handleScan = require("./utils/scan/handleScan");
|
|
41
42
|
var import_scanCache = __toESM(require("./utils/scan/scanCache"));
|
|
42
43
|
var import_cartView = require("./utils/cartView");
|
|
@@ -76,10 +77,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
76
77
|
async initialize(core, options = {}) {
|
|
77
78
|
var _a;
|
|
78
79
|
this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
|
|
79
|
-
this.shopStore = core.getPlugin("shopStore");
|
|
80
|
-
if (!this.shopStore) {
|
|
81
|
-
throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
|
|
82
|
-
}
|
|
83
80
|
await super.initialize(core, options);
|
|
84
81
|
if (!this.request) {
|
|
85
82
|
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
@@ -111,7 +108,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
111
108
|
country_calling_code: detailCustomer == null ? void 0 : detailCustomer.country_calling_code
|
|
112
109
|
};
|
|
113
110
|
customerModule.setSelectedCustomer(customer);
|
|
114
|
-
this.setOrderCustomer(customer
|
|
111
|
+
this.setOrderCustomer(customer);
|
|
115
112
|
}
|
|
116
113
|
return sales;
|
|
117
114
|
}
|
|
@@ -259,33 +256,20 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
259
256
|
/**
|
|
260
257
|
* 获取购物车 UI 视图。
|
|
261
258
|
*
|
|
262
|
-
* tempOrder 仍是 checkout
|
|
263
|
-
* 商品行展示字段在 Solution 层合并,避免 UI 直接读取 tempOrder 原始结构。
|
|
259
|
+
* tempOrder 仍是 checkout 协议对象;商品行直接透传 products,bookings 附带关联商品。
|
|
264
260
|
*/
|
|
265
261
|
getCart() {
|
|
266
262
|
var _a;
|
|
267
263
|
const tempOrder = ((_a = this.store.order) == null ? void 0 : _a.getTempOrder()) ?? null;
|
|
268
264
|
const salesDetail = this.getSalesOrder();
|
|
269
265
|
const bookings = (salesDetail == null ? void 0 : salesDetail.bookings) ?? ((tempOrder == null ? void 0 : tempOrder.bookings) || []);
|
|
270
|
-
|
|
271
|
-
const bookingsByProductUid = salesDetailBookingMap && Object.keys(salesDetailBookingMap).length > 0 ? salesDetailBookingMap : (0, import_cartView.indexBookingsByProductUid)(bookings);
|
|
272
|
-
return {
|
|
273
|
-
items: (0, import_cartView.buildCartItemViews)((tempOrder == null ? void 0 : tempOrder.products) || [], {
|
|
274
|
-
bookingDetailMap: bookingsByProductUid,
|
|
275
|
-
productsCatalog: this.productCatalog
|
|
276
|
-
})
|
|
277
|
-
};
|
|
266
|
+
return (0, import_cartView.buildCartView)((tempOrder == null ? void 0 : tempOrder.products) || [], bookings);
|
|
278
267
|
}
|
|
279
268
|
/**
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* 优先使用 CustomerModule 的 selected customer;缺失时回退到 tempOrder 顶层客户字段。
|
|
269
|
+
* 获取当前下单客户(与 OrderModule.tempOrder snapshot 一致)。
|
|
283
270
|
*/
|
|
284
271
|
getCustomer() {
|
|
285
|
-
|
|
286
|
-
const selected = ((_b = (_a = this.store.customer) == null ? void 0 : _a.getSelectedCustomer) == null ? void 0 : _b.call(_a)) ?? null;
|
|
287
|
-
const tempOrder = ((_d = (_c = this.store.order) == null ? void 0 : _c.getTempOrder) == null ? void 0 : _d.call(_c)) ?? null;
|
|
288
|
-
return (0, import_cartView.buildCustomerView)(selected, tempOrder);
|
|
272
|
+
return this.getOrderCustomerSnapshot();
|
|
289
273
|
}
|
|
290
274
|
/**
|
|
291
275
|
* 通过 ids 获取商品列表(不加载到模块中)
|
|
@@ -387,16 +371,22 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
387
371
|
/**
|
|
388
372
|
* 设置当前下单客户。
|
|
389
373
|
*
|
|
390
|
-
* @param
|
|
391
|
-
*
|
|
374
|
+
* @param customer 完整客户对象;null 表示清空
|
|
375
|
+
*
|
|
376
|
+
* 内部将 customer 格式化为 tempOrder 协议字段后写入 OrderModule,
|
|
377
|
+
* 并以 customer 作为 snapshot 保存富字段。
|
|
392
378
|
*
|
|
393
379
|
* 同时透传 OrderModule 内部 emit 的 `order:onOrderCustomerChange` 之外,
|
|
394
380
|
* 在 BookingTicket 命名空间也 emit 一次,方便上层统一从 Solution 订阅。
|
|
395
381
|
*/
|
|
396
|
-
setOrderCustomer(
|
|
397
|
-
|
|
382
|
+
setOrderCustomer(customer) {
|
|
383
|
+
if (!customer) {
|
|
384
|
+
this.clearOrderCustomer();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
const patch = (0, import_orderCustomer.formatOrderCustomerPatch)(customer);
|
|
388
|
+
this.store.order.setOrderCustomer(patch, customer);
|
|
398
389
|
const next = this.buildOrderCustomerPayload();
|
|
399
|
-
console.log("setOrderCustomer1234", patch, snapshot, next);
|
|
400
390
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
401
391
|
}
|
|
402
392
|
/**
|
|
@@ -94,21 +94,24 @@ export interface IScanResult {
|
|
|
94
94
|
result: any;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
|
-
* BookingTicket 面向 UI
|
|
97
|
+
* BookingTicket 面向 UI 的购物车商品行视图。
|
|
98
98
|
*
|
|
99
|
-
* tempOrder.products
|
|
100
|
-
* 避免 UI 直接读取 booking/detail/catalog 等原始来源。
|
|
99
|
+
* 直接透传 tempOrder.products 协议行,不做 Solution 层 enrichment。
|
|
101
100
|
*/
|
|
102
|
-
export
|
|
103
|
-
|
|
101
|
+
export type BookingTicketCartItemView = BaseSalesOrderProduct;
|
|
102
|
+
/**
|
|
103
|
+
* BookingTicket 面向 UI 的 booking 行视图(平铺,附带关联商品)。
|
|
104
|
+
*/
|
|
105
|
+
export interface BookingTicketCartBookingView extends ISalesBooking {
|
|
104
106
|
_extend: {
|
|
105
|
-
|
|
107
|
+
product: BookingTicketCartItemView | null;
|
|
106
108
|
};
|
|
107
109
|
}
|
|
108
110
|
/**
|
|
109
111
|
* BookingTicket 面向 UI 的购物车视图。
|
|
110
112
|
*/
|
|
111
113
|
export interface BookingTicketCartView {
|
|
114
|
+
bookings: BookingTicketCartBookingView[];
|
|
112
115
|
items: BookingTicketCartItemView[];
|
|
113
116
|
}
|
|
114
117
|
/**
|
|
@@ -1,24 +1,19 @@
|
|
|
1
1
|
import type { BaseSalesOrderProduct } from '../../BaseSales';
|
|
2
2
|
import type { ISalesBooking } from '../../BaseSales/utils/parseSalesResponse';
|
|
3
|
-
import type {
|
|
4
|
-
import type { BookingTicketCartItemView, BookingTicketCustomerView, ICustomer } from '../types';
|
|
3
|
+
import type { BookingTicketCartView, BookingTicketCustomerView, ICustomer } from '../types';
|
|
5
4
|
import type { ScanOrderTempOrder } from '../../ScanOrder/types';
|
|
6
5
|
/**
|
|
7
6
|
* 仅按 booking.product_uid 建索引,避免发明 booking 与商品行之间的其它等价关系。
|
|
8
7
|
*/
|
|
9
8
|
export declare function indexBookingsByProductUid(bookings: ISalesBooking[] | undefined | null): Record<string, ISalesBooking[]>;
|
|
10
9
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* 构建购物车 UI 视图:bookings 平铺附带关联商品;items 仅含未关联 booking 的商品行。
|
|
11
|
+
*
|
|
12
|
+
* 商品行直接透传 tempOrder.products,不做 enrichment。
|
|
13
|
+
* 关联规则(1:1):booking.product_uid ↔ line.metadata.unique_identification_number;
|
|
14
|
+
* 同一 uid 已被更早的 booking 占用时,后续 booking 的 product 为 null。
|
|
13
15
|
*/
|
|
14
|
-
export declare function
|
|
15
|
-
bookingDetailMap?: Record<string, ISalesBooking[]>;
|
|
16
|
-
productsCatalog: ProductData[];
|
|
17
|
-
}): BookingTicketCartItemView;
|
|
18
|
-
export declare function buildCartItemViews(lines: BaseSalesOrderProduct[] | undefined | null, ctx: {
|
|
19
|
-
bookingDetailMap?: Record<string, ISalesBooking[]>;
|
|
20
|
-
productsCatalog: ProductData[];
|
|
21
|
-
}): BookingTicketCartItemView[];
|
|
16
|
+
export declare function buildCartView(lines: BaseSalesOrderProduct[] | undefined | null, bookings: ISalesBooking[] | undefined | null): BookingTicketCartView;
|
|
22
17
|
export declare function isWalkInCustomer(customer: Pick<ICustomer, 'id'> | null | undefined): boolean;
|
|
23
18
|
/**
|
|
24
19
|
* selected 优先,缺失时回退 tempOrder.customer_*,统一输出 UI 客户视图。
|
|
@@ -19,8 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/solution/BookingTicket/utils/cartView.ts
|
|
20
20
|
var cartView_exports = {};
|
|
21
21
|
__export(cartView_exports, {
|
|
22
|
-
|
|
23
|
-
buildCartItemViews: () => buildCartItemViews,
|
|
22
|
+
buildCartView: () => buildCartView,
|
|
24
23
|
buildCustomerView: () => buildCustomerView,
|
|
25
24
|
indexBookingsByProductUid: () => indexBookingsByProductUid,
|
|
26
25
|
isWalkInCustomer: () => isWalkInCustomer
|
|
@@ -40,21 +39,49 @@ function indexBookingsByProductUid(bookings) {
|
|
|
40
39
|
return acc;
|
|
41
40
|
}, {});
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
function indexProductsByUid(lines) {
|
|
43
|
+
return lines.reduce((acc, line) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
46
|
+
if (uid === void 0 || uid === null || uid === "")
|
|
47
|
+
return acc;
|
|
48
|
+
const key = String(uid);
|
|
49
|
+
if (!acc[key])
|
|
50
|
+
acc[key] = line;
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
function buildCartView(lines, bookings) {
|
|
55
|
+
const productLines = Array.isArray(lines) ? lines : [];
|
|
56
|
+
const bookingList = Array.isArray(bookings) ? bookings : [];
|
|
57
|
+
const linesByUid = indexProductsByUid(productLines);
|
|
58
|
+
const claimedUids = /* @__PURE__ */ new Set();
|
|
59
|
+
const cartBookings = bookingList.filter((booking) => booking.parent_id !== 0).map((booking) => {
|
|
60
|
+
const uid = booking == null ? void 0 : booking.product_uid;
|
|
61
|
+
let product = null;
|
|
62
|
+
if (uid !== void 0 && uid !== null && uid !== "") {
|
|
63
|
+
const key = String(uid);
|
|
64
|
+
if (!claimedUids.has(key)) {
|
|
65
|
+
const line = linesByUid[key];
|
|
66
|
+
if (line) {
|
|
67
|
+
claimedUids.add(key);
|
|
68
|
+
product = line;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...booking,
|
|
74
|
+
_extend: { product }
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
const items = productLines.filter((line) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
80
|
+
if (uid === void 0 || uid === null || uid === "")
|
|
81
|
+
return true;
|
|
82
|
+
return !claimedUids.has(String(uid));
|
|
83
|
+
});
|
|
84
|
+
return { bookings: cartBookings, items };
|
|
58
85
|
}
|
|
59
86
|
function isWalkInCustomer(customer) {
|
|
60
87
|
if (!customer)
|
|
@@ -95,8 +122,7 @@ function buildCustomerView(selected, tempOrder) {
|
|
|
95
122
|
}
|
|
96
123
|
// Annotate the CommonJS export names for ESM import in node:
|
|
97
124
|
0 && (module.exports = {
|
|
98
|
-
|
|
99
|
-
buildCartItemViews,
|
|
125
|
+
buildCartView,
|
|
100
126
|
buildCustomerView,
|
|
101
127
|
indexBookingsByProductUid,
|
|
102
128
|
isWalkInCustomer
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/solution/BookingTicket/utils/orderCustomer.ts
|
|
20
|
+
var orderCustomer_exports = {};
|
|
21
|
+
__export(orderCustomer_exports, {
|
|
22
|
+
formatOrderCustomerPatch: () => formatOrderCustomerPatch
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(orderCustomer_exports);
|
|
25
|
+
function resolveCustomerDisplayName(customer) {
|
|
26
|
+
const c = customer;
|
|
27
|
+
const displayName = c.display_name;
|
|
28
|
+
if (typeof displayName === "string" && displayName)
|
|
29
|
+
return displayName;
|
|
30
|
+
const nickname = c.nickname;
|
|
31
|
+
if (typeof nickname === "string" && nickname)
|
|
32
|
+
return nickname;
|
|
33
|
+
const firstName = c.first_name;
|
|
34
|
+
const lastName = c.last_name;
|
|
35
|
+
if (typeof firstName === "string" && firstName || typeof lastName === "string" && lastName) {
|
|
36
|
+
return `${typeof firstName === "string" ? firstName : ""} ${typeof lastName === "string" ? lastName : ""}`.trim();
|
|
37
|
+
}
|
|
38
|
+
const customerName = c.customer_name;
|
|
39
|
+
if (typeof customerName === "string" && customerName)
|
|
40
|
+
return customerName;
|
|
41
|
+
return customer.name ?? "";
|
|
42
|
+
}
|
|
43
|
+
function formatOrderCustomerPatch(customer) {
|
|
44
|
+
var _a;
|
|
45
|
+
const rawId = customer.id;
|
|
46
|
+
const numericId = typeof rawId === "number" ? rawId : rawId !== void 0 && rawId !== null && rawId !== "" ? Number(rawId) : null;
|
|
47
|
+
return {
|
|
48
|
+
customer_id: Number.isFinite(numericId) ? numericId : null,
|
|
49
|
+
customer_name: resolveCustomerDisplayName(customer),
|
|
50
|
+
phone: customer.phone ?? "",
|
|
51
|
+
email: customer.email ?? "",
|
|
52
|
+
country_calling_code: ((_a = customer.country_calling_code) == null ? void 0 : _a.toString()) ?? ""
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
formatOrderCustomerPatch
|
|
58
|
+
});
|
|
@@ -82,6 +82,9 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
82
82
|
private getResourceId;
|
|
83
83
|
private getBookingAppointmentStatus;
|
|
84
84
|
private getBookingOrderPaymentStatus;
|
|
85
|
+
private countBookingOrders;
|
|
86
|
+
private countCompletedBookings;
|
|
87
|
+
private groupBookingsByResource;
|
|
85
88
|
private isBookingMatchedResource;
|
|
86
89
|
private sortMatchedBookings;
|
|
87
90
|
/**
|
|
@@ -254,6 +254,37 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
254
254
|
var _a;
|
|
255
255
|
return String(((_a = booking.order) == null ? void 0 : _a.payment_status) ?? "");
|
|
256
256
|
}
|
|
257
|
+
countBookingOrders(bookings) {
|
|
258
|
+
const orderIds = /* @__PURE__ */ new Set();
|
|
259
|
+
bookings.forEach((booking) => {
|
|
260
|
+
var _a;
|
|
261
|
+
const orderId = booking.order_id ?? ((_a = booking.order) == null ? void 0 : _a.order_id);
|
|
262
|
+
if (orderId === void 0 || orderId === null)
|
|
263
|
+
return;
|
|
264
|
+
orderIds.add(String(orderId));
|
|
265
|
+
});
|
|
266
|
+
return orderIds.size;
|
|
267
|
+
}
|
|
268
|
+
countCompletedBookings(bookings) {
|
|
269
|
+
return bookings.filter((booking) => this.getBookingAppointmentStatus(booking) === "completed").length;
|
|
270
|
+
}
|
|
271
|
+
groupBookingsByResource(bookingList) {
|
|
272
|
+
const bookingMap = /* @__PURE__ */ new Map();
|
|
273
|
+
bookingList.forEach((booking) => {
|
|
274
|
+
if (!Array.isArray(booking.resources))
|
|
275
|
+
return;
|
|
276
|
+
booking.resources.forEach((resource) => {
|
|
277
|
+
const relationId = resource == null ? void 0 : resource.relation_id;
|
|
278
|
+
if (relationId === void 0 || relationId === null)
|
|
279
|
+
return;
|
|
280
|
+
const key = String(relationId);
|
|
281
|
+
const list = bookingMap.get(key) || [];
|
|
282
|
+
list.push(booking);
|
|
283
|
+
bookingMap.set(key, list);
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
return bookingMap;
|
|
287
|
+
}
|
|
257
288
|
isBookingMatchedResource(booking, resourceId) {
|
|
258
289
|
if (!Array.isArray(booking.resources))
|
|
259
290
|
return false;
|
|
@@ -534,27 +565,22 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
534
565
|
if (!Array.isArray(resourceList) || resourceList.length === 0)
|
|
535
566
|
return [];
|
|
536
567
|
const normalizedBookings = this.normalizeResourceBookings(current, deviceCurrent, bookingList);
|
|
537
|
-
const
|
|
538
|
-
|
|
539
|
-
if (!Array.isArray(booking.resources))
|
|
540
|
-
return;
|
|
541
|
-
booking.resources.forEach((resource) => {
|
|
542
|
-
const relationId = resource == null ? void 0 : resource.relation_id;
|
|
543
|
-
if (relationId === void 0 || relationId === null)
|
|
544
|
-
return;
|
|
545
|
-
const key = String(relationId);
|
|
546
|
-
const list2 = bookingMap.get(key) || [];
|
|
547
|
-
list2.push(booking);
|
|
548
|
-
bookingMap.set(key, list2);
|
|
549
|
-
});
|
|
550
|
-
});
|
|
568
|
+
const rawBookingMap = this.groupBookingsByResource(bookingList);
|
|
569
|
+
const bookingMap = this.groupBookingsByResource(normalizedBookings);
|
|
551
570
|
const list = resourceList.map((resource) => {
|
|
552
571
|
const resourceId = this.getResourceId(resource);
|
|
572
|
+
const rawMatchedBookings = rawBookingMap.get(String(resourceId)) || [];
|
|
553
573
|
const matchedBookings = bookingMap.get(String(resourceId)) || [];
|
|
574
|
+
const orderCount = this.countBookingOrders(rawMatchedBookings);
|
|
575
|
+
const bookingCount = rawMatchedBookings.length;
|
|
576
|
+
const compeleteBookingCount = this.countCompletedBookings(rawMatchedBookings);
|
|
554
577
|
const bookings = this.pickBookingsForCurrentPoint(current, matchedBookings);
|
|
555
578
|
return {
|
|
556
579
|
...resource,
|
|
557
580
|
resource_id: resourceId,
|
|
581
|
+
orderCount,
|
|
582
|
+
bookingCount,
|
|
583
|
+
compeleteBookingCount,
|
|
558
584
|
bookings
|
|
559
585
|
};
|
|
560
586
|
});
|
|
@@ -616,6 +642,9 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
616
642
|
current,
|
|
617
643
|
this.normalizeResourceBookings(current, deviceCurrent, unpaidBookingList)
|
|
618
644
|
);
|
|
645
|
+
const orderCount = this.countBookingOrders(matchedBookingList);
|
|
646
|
+
const bookingCount = matchedBookingList.length;
|
|
647
|
+
const compeleteBookingCount = completedBookingList.length;
|
|
619
648
|
this.logger.addLog({
|
|
620
649
|
type: "info",
|
|
621
650
|
title: "getResourceBookingItem",
|
|
@@ -626,12 +655,18 @@ var SalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
626
655
|
bookingList: (_b = params.bookingList) == null ? void 0 : _b.length,
|
|
627
656
|
bookings: bookings.length,
|
|
628
657
|
completedBookings: completedBookings.length,
|
|
629
|
-
unpaidBookings: unpaidBookings.length
|
|
658
|
+
unpaidBookings: unpaidBookings.length,
|
|
659
|
+
orderCount,
|
|
660
|
+
bookingCount,
|
|
661
|
+
compeleteBookingCount
|
|
630
662
|
}
|
|
631
663
|
});
|
|
632
664
|
return {
|
|
633
665
|
...targetResource,
|
|
634
666
|
resource_id: resourceId,
|
|
667
|
+
orderCount,
|
|
668
|
+
bookingCount,
|
|
669
|
+
compeleteBookingCount,
|
|
635
670
|
bookings,
|
|
636
671
|
completedBookings,
|
|
637
672
|
unpaidBookings
|
|
@@ -30,6 +30,9 @@ export interface SalesResourceMatchedBooking extends Omit<BookingData, 'status'>
|
|
|
30
30
|
}
|
|
31
31
|
export interface SalesResourceBookingItem extends Omit<ResourceData, 'bookings'> {
|
|
32
32
|
resource_id: ResourceId;
|
|
33
|
+
orderCount: number;
|
|
34
|
+
bookingCount: number;
|
|
35
|
+
compeleteBookingCount: number;
|
|
33
36
|
bookings: SalesResourceMatchedBooking[];
|
|
34
37
|
}
|
|
35
38
|
export interface SalesResourceBookingItemWithGroups extends SalesResourceBookingItem {
|
|
@@ -85,13 +85,13 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
|
85
85
|
* 出站 payload 版本的商品行。
|
|
86
86
|
*
|
|
87
87
|
* 与 tempOrder 内部 `ScanOrderOrderProduct` 的字段差异:
|
|
88
|
-
* - `product_option_item[*]`:内部为 `{
|
|
89
|
-
*
|
|
88
|
+
* - `product_option_item[*]`:内部为 `{ option_group_item_id, option_group_id, num, price, ... }`,
|
|
89
|
+
* 出站保留 `{ option_group_item_id, option_group_id, num }`
|
|
90
90
|
* (后端 checkout 协议;丢弃 `price` 等运行时辅助字段)。
|
|
91
91
|
* - `product_bundle[*].option[*]`:同上重命名规则。
|
|
92
92
|
*
|
|
93
|
-
* 运行时(UI
|
|
94
|
-
*
|
|
93
|
+
* 运行时(UI 显示、加购合并、指纹、持久化)与提交边界统一消费字段名
|
|
94
|
+
* `option_group_item_id`,保持 tempOrder 与后端协议一致。
|
|
95
95
|
*/
|
|
96
96
|
export interface ScanOrderSubmitProduct extends Omit<ScanOrderOrderProduct, '_origin' | 'identity_key'> {
|
|
97
97
|
/**
|
|
@@ -349,13 +349,13 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
|
|
|
349
349
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
350
350
|
const optArr = Array.isArray(productOptionItem) ? productOptionItem : [];
|
|
351
351
|
const normalizedOpts = optArr.map((item) => ({
|
|
352
|
-
|
|
352
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
353
353
|
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
354
354
|
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
355
355
|
price: String((item == null ? void 0 : item.price) ?? "")
|
|
356
356
|
})).sort((p, q) => {
|
|
357
|
-
if (p.
|
|
358
|
-
return p.
|
|
357
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
358
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
359
359
|
}
|
|
360
360
|
if (p.option_group_id !== q.option_group_id)
|
|
361
361
|
return p.option_group_id - q.option_group_id;
|