@pisell/pisellos 2.2.167 → 2.2.168
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/Discount/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +3 -9
- package/dist/modules/Order/index.js +6 -2
- package/dist/modules/Order/types.d.ts +8 -0
- package/dist/modules/Order/utils.js +1 -1
- package/dist/server/modules/order/utils/filterOrders.js +20 -6
- package/dist/solution/BaseSales/index.js +11 -5
- package/dist/solution/BookingTicket/index.d.ts +10 -1
- package/dist/solution/BookingTicket/index.js +369 -189
- package/dist/solution/VenueBooking/index.d.ts +1 -6
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +3 -9
- package/lib/modules/Order/index.js +6 -2
- package/lib/modules/Order/types.d.ts +8 -0
- package/lib/modules/Order/utils.js +1 -1
- package/lib/server/modules/order/utils/filterOrders.js +12 -4
- package/lib/solution/BaseSales/index.js +6 -0
- package/lib/solution/BookingTicket/index.d.ts +10 -1
- package/lib/solution/BookingTicket/index.js +77 -0
- package/lib/solution/VenueBooking/index.d.ts +1 -6
- package/package.json +1 -1
|
@@ -135,6 +135,7 @@ export interface Discount {
|
|
|
135
135
|
appliedProductDetails: ApplicableProductDetails[];
|
|
136
136
|
isDisabledForProductUsed?: boolean;
|
|
137
137
|
amount?: number;
|
|
138
|
+
customer_id?: number | string | null;
|
|
138
139
|
extension_data?: ExtensionData[];
|
|
139
140
|
total_order_behavior_count?: number;
|
|
140
141
|
today_order_behavior_count?: number;
|
|
@@ -3,10 +3,9 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CheckoutOrderParams, CancelOrderParams, ChangeBookingStatusParams } 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, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions } from './types';
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, OrderScanCodeResult, ReplaceTempOrderOptions } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
|
-
import { UnavailableReason } from '../Rules/types';
|
|
10
9
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
11
10
|
protected defaultName: string;
|
|
12
11
|
protected defaultVersion: string;
|
|
@@ -48,12 +47,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
48
47
|
apply?: boolean;
|
|
49
48
|
}): Promise<Discount[]>;
|
|
50
49
|
getDiscountList(): Discount[];
|
|
51
|
-
scanCode(code: string, customerId?: number): Promise<
|
|
52
|
-
isAvailable: boolean;
|
|
53
|
-
discountList: Discount[];
|
|
54
|
-
type: 'server' | 'clientCalc';
|
|
55
|
-
unavailableReason?: UnavailableReason;
|
|
56
|
-
}>;
|
|
50
|
+
scanCode(code: string, customerId?: number): Promise<OrderScanCodeResult>;
|
|
57
51
|
applyDiscount(): void;
|
|
58
52
|
initTempOrder(params: {
|
|
59
53
|
cacheId?: string;
|
|
@@ -190,7 +184,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
190
184
|
private logSubmitBackendRejected;
|
|
191
185
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
192
186
|
createOrder(params: CommitOrderParams['query']): {
|
|
193
|
-
type: "
|
|
187
|
+
type: "appointment_booking" | "virtual";
|
|
194
188
|
platform: string;
|
|
195
189
|
sales_channel: string;
|
|
196
190
|
order_sales_channel: string;
|
|
@@ -277,6 +277,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
277
277
|
type: 'clientCalc',
|
|
278
278
|
isAvailable: false,
|
|
279
279
|
discountList: this.getDiscountList(),
|
|
280
|
+
scannedDiscountList: resultDiscountList,
|
|
280
281
|
unavailableReason: UnavailableReason.Unknown
|
|
281
282
|
});
|
|
282
283
|
case 9:
|
|
@@ -287,7 +288,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
287
288
|
return _context3.abrupt("return", {
|
|
288
289
|
type: 'server',
|
|
289
290
|
isAvailable: false,
|
|
290
|
-
discountList: this.getDiscountList()
|
|
291
|
+
discountList: this.getDiscountList(),
|
|
292
|
+
scannedDiscountList: resultDiscountList
|
|
291
293
|
});
|
|
292
294
|
case 11:
|
|
293
295
|
withScanList = resultDiscountList.map(function (item) {
|
|
@@ -309,7 +311,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
309
311
|
return _context3.abrupt("return", {
|
|
310
312
|
type: 'clientCalc',
|
|
311
313
|
isAvailable: true,
|
|
312
|
-
discountList: this.getDiscountList()
|
|
314
|
+
discountList: this.getDiscountList(),
|
|
315
|
+
scannedDiscountList: resultDiscountList
|
|
313
316
|
});
|
|
314
317
|
case 15:
|
|
315
318
|
tempOrder = this.store.tempOrder;
|
|
@@ -335,6 +338,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
335
338
|
type: 'clientCalc',
|
|
336
339
|
isAvailable: isAvailable || false,
|
|
337
340
|
discountList: newDiscountList || this.getDiscountList(),
|
|
341
|
+
scannedDiscountList: resultDiscountList,
|
|
338
342
|
unavailableReason: unavailableReason
|
|
339
343
|
});
|
|
340
344
|
case 20:
|
|
@@ -2,6 +2,7 @@ import { CartItem } from '../Cart/types';
|
|
|
2
2
|
import type { DiscountModule } from '../Discount';
|
|
3
3
|
import type { RulesModule } from '../Rules';
|
|
4
4
|
import type { Discount } from '../Discount/types';
|
|
5
|
+
import type { UnavailableReason } from '../Rules/types';
|
|
5
6
|
import type { SubmitPayloadEnhancer } from './utils';
|
|
6
7
|
import type { PaymentItem } from '../Payment/types';
|
|
7
8
|
import type { ICustomer } from '../AccountList/types';
|
|
@@ -48,6 +49,13 @@ export interface OrderCustomerChangePayload {
|
|
|
48
49
|
patch: OrderCustomerView;
|
|
49
50
|
snapshot: ICustomer | null;
|
|
50
51
|
}
|
|
52
|
+
export interface OrderScanCodeResult {
|
|
53
|
+
isAvailable: boolean;
|
|
54
|
+
discountList: Discount[];
|
|
55
|
+
scannedDiscountList: Discount[];
|
|
56
|
+
type: 'server' | 'clientCalc';
|
|
57
|
+
unavailableReason?: UnavailableReason;
|
|
58
|
+
}
|
|
51
59
|
export interface OrderProductIdentity {
|
|
52
60
|
product_id: number | null;
|
|
53
61
|
product_variant_id: number;
|
|
@@ -655,7 +655,7 @@ export function buildSubmitPayload(params) {
|
|
|
655
655
|
note: tempOrder.note || '',
|
|
656
656
|
delivery_type: tempOrder.delivery_type || 'nil',
|
|
657
657
|
schedule_date: scheduleDate,
|
|
658
|
-
created_at: tempOrder.created_at || formatDateTime(now),
|
|
658
|
+
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
659
659
|
bookings: (tempOrder.bookings || []).filter(function (booking) {
|
|
660
660
|
return Number(booking.parent_id) !== 0;
|
|
661
661
|
}).map(function (booking) {
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
|
+
/** 从订单 payments 提取支付方式 code,与 UI 筛选选项及 filterBookings 一致 */
|
|
3
|
+
function getOrderPaymentCodes(order) {
|
|
4
|
+
var payments = order.payments;
|
|
5
|
+
if (!Array.isArray(payments) || payments.length === 0) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return payments.map(function (item) {
|
|
9
|
+
return item === null || item === void 0 ? void 0 : item.code;
|
|
10
|
+
}).filter(function (code) {
|
|
11
|
+
return typeof code === 'string' && code.length > 0;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
2
15
|
/**
|
|
3
16
|
* 订单过滤函数
|
|
4
17
|
* @param orders 原始订单列表
|
|
@@ -126,22 +139,23 @@ export function filterOrders(orders, filters) {
|
|
|
126
139
|
}
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
// payment_methods -
|
|
142
|
+
// payment_methods - 支付方式(按 payments[].code 匹配,不再使用 order.payment_methods)
|
|
130
143
|
if (safeFilters.payment_methods && safeFilters.payment_methods.length > 0) {
|
|
131
|
-
|
|
144
|
+
var orderPaymentCodes = getOrderPaymentCodes(order);
|
|
145
|
+
if (orderPaymentCodes.length === 0) {
|
|
132
146
|
rejected.push({
|
|
133
147
|
order_id: order.order_id,
|
|
134
148
|
order_number: order.order_number,
|
|
135
149
|
reason: {
|
|
136
150
|
field: 'payment_methods',
|
|
137
|
-
actual: order.
|
|
151
|
+
actual: order.payments,
|
|
138
152
|
expected: safeFilters.payment_methods
|
|
139
153
|
}
|
|
140
154
|
});
|
|
141
155
|
return false;
|
|
142
156
|
}
|
|
143
|
-
var hasMatch =
|
|
144
|
-
return safeFilters.payment_methods.includes(
|
|
157
|
+
var hasMatch = orderPaymentCodes.some(function (code) {
|
|
158
|
+
return safeFilters.payment_methods.includes(code);
|
|
145
159
|
});
|
|
146
160
|
if (!hasMatch) {
|
|
147
161
|
rejected.push({
|
|
@@ -149,7 +163,7 @@ export function filterOrders(orders, filters) {
|
|
|
149
163
|
order_number: order.order_number,
|
|
150
164
|
reason: {
|
|
151
165
|
field: 'payment_methods',
|
|
152
|
-
actual:
|
|
166
|
+
actual: orderPaymentCodes,
|
|
153
167
|
expected: safeFilters.payment_methods
|
|
154
168
|
}
|
|
155
169
|
});
|
|
@@ -1348,17 +1348,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1348
1348
|
});
|
|
1349
1349
|
case 48:
|
|
1350
1350
|
this.store.order.persistTempOrder();
|
|
1351
|
-
|
|
1351
|
+
this.effectsEmit('onDiscountApplied', {
|
|
1352
|
+
productList: tempOrder.products,
|
|
1353
|
+
discountList: nextDiscountList,
|
|
1354
|
+
selectedDiscountList: tempOrder.discount_list,
|
|
1355
|
+
tempOrder: tempOrder
|
|
1356
|
+
});
|
|
1357
|
+
_context14.next = 55;
|
|
1352
1358
|
break;
|
|
1353
|
-
case
|
|
1354
|
-
_context14.prev =
|
|
1359
|
+
case 52:
|
|
1360
|
+
_context14.prev = 52;
|
|
1355
1361
|
_context14.t1 = _context14["catch"](0);
|
|
1356
1362
|
throw _context14.t1;
|
|
1357
|
-
case
|
|
1363
|
+
case 55:
|
|
1358
1364
|
case "end":
|
|
1359
1365
|
return _context14.stop();
|
|
1360
1366
|
}
|
|
1361
|
-
}, _callee14, this, [[0,
|
|
1367
|
+
}, _callee14, this, [[0, 52], [16, 36, 39, 42]]);
|
|
1362
1368
|
}));
|
|
1363
1369
|
function setDiscountSelected(_x9) {
|
|
1364
1370
|
return _setDiscountSelected.apply(this, arguments);
|
|
@@ -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
|
*
|
|
@@ -251,7 +260,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
251
260
|
* 获取当前的客户搜索条件
|
|
252
261
|
* @returns 当前搜索条件
|
|
253
262
|
*/
|
|
254
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
263
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
255
264
|
/**
|
|
256
265
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
257
266
|
* @returns 客户状态
|