@pisell/pisellos 0.0.491 → 0.0.492
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/apis/picoding.d.ts +0 -0
- package/dist/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/utils.js +2 -2
- package/dist/modules/OpenData/index.d.ts +23 -0
- package/dist/modules/OpenData/index.js +167 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +54 -2
- package/dist/modules/Order/index.js +717 -27
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +25 -0
- package/dist/modules/Order/utils.js +214 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -1
- package/dist/modules/Quotation/index.d.ts +40 -0
- package/dist/modules/Quotation/index.js +212 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +506 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +378 -0
- package/dist/solution/VenueBooking/index.d.ts +159 -0
- package/dist/solution/VenueBooking/index.js +2773 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +123 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +128 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -2
- package/lib/modules/OpenData/index.d.ts +23 -0
- package/lib/modules/OpenData/index.js +116 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +54 -2
- package/lib/modules/Order/index.js +389 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +25 -0
- package/lib/modules/Order/utils.js +217 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +40 -0
- package/lib/modules/Quotation/index.js +128 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +445 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +342 -0
- package/lib/solution/VenueBooking/index.d.ts +159 -0
- package/lib/solution/VenueBooking/index.js +1508 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +123 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +156 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { getDateIsInSchedule } from "../Schedule/getDateIsInSchedule";
|
|
4
|
+
function toBoolean(value) {
|
|
5
|
+
if (typeof value === 'boolean') return value;
|
|
6
|
+
if (typeof value === 'string') return value === 'true' || value === '1';
|
|
7
|
+
if (typeof value === 'number') return value !== 0;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
function resolveMessage() {
|
|
11
|
+
for (var _len = arguments.length, candidates = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
|
+
candidates[_key] = arguments[_key];
|
|
13
|
+
}
|
|
14
|
+
for (var _i = 0, _candidates = candidates; _i < _candidates.length; _i++) {
|
|
15
|
+
var val = _candidates[_i];
|
|
16
|
+
if (!val) continue;
|
|
17
|
+
if (typeof val === 'string' && val.length > 0) return val;
|
|
18
|
+
if (_typeof(val) === 'object' && val !== null && !Array.isArray(val)) return val;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export function computeAvailability(params) {
|
|
23
|
+
var config = params.config,
|
|
24
|
+
scheduleList = params.scheduleList;
|
|
25
|
+
if (!config) {
|
|
26
|
+
return {
|
|
27
|
+
available: true,
|
|
28
|
+
reason: null,
|
|
29
|
+
message: null
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (config['basic.enable'] === false) {
|
|
33
|
+
return {
|
|
34
|
+
available: false,
|
|
35
|
+
reason: 'shop_disabled',
|
|
36
|
+
message: resolveMessage(config['basic.unavailable_message'], config['availability.closed_message'])
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (toBoolean(config['availability.paused'])) {
|
|
40
|
+
return {
|
|
41
|
+
available: false,
|
|
42
|
+
reason: 'paused',
|
|
43
|
+
message: resolveMessage(config['availability.pause_message'], config['availability.closed_message'])
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
var operatingHourIds = config['availability.operating_hours'];
|
|
47
|
+
if (Array.isArray(operatingHourIds) && operatingHourIds.length > 0 && scheduleList !== null && scheduleList !== void 0 && scheduleList.length) {
|
|
48
|
+
var relevantSchedules = scheduleList.filter(function (s) {
|
|
49
|
+
return operatingHourIds.includes(s.id);
|
|
50
|
+
});
|
|
51
|
+
if (relevantSchedules.length > 0) {
|
|
52
|
+
var now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
53
|
+
var isOpen = getDateIsInSchedule(now, relevantSchedules);
|
|
54
|
+
if (!isOpen) {
|
|
55
|
+
return {
|
|
56
|
+
available: false,
|
|
57
|
+
reason: 'closed',
|
|
58
|
+
message: resolveMessage(config['availability.closed_message'])
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (config['reservation.enable'] === false) {
|
|
64
|
+
return {
|
|
65
|
+
available: false,
|
|
66
|
+
reason: 'reservation_disabled',
|
|
67
|
+
message: resolveMessage(config['availability.closed_message'])
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
available: true,
|
|
72
|
+
reason: null,
|
|
73
|
+
message: null
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { OrderModuleAPI, CommitOrderParams, CheckoutOrderParams } from './types';
|
|
3
|
+
import { OrderModuleAPI, CommitOrderParams, SubmitScanOrderParams, ScanOrderMoreParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
|
+
import type { ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
|
|
6
|
+
import type { Discount } from '../Discount/types';
|
|
7
|
+
import { UnavailableReason } from '../Rules/types';
|
|
5
8
|
export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
|
|
6
9
|
protected defaultName: string;
|
|
7
10
|
protected defaultVersion: string;
|
|
8
11
|
private store;
|
|
9
12
|
private request;
|
|
10
13
|
private logger;
|
|
14
|
+
private window;
|
|
15
|
+
private cacheId;
|
|
16
|
+
private salesSummaryModuleName;
|
|
17
|
+
private rulesHooksOverride?;
|
|
11
18
|
constructor(name?: string, version?: string);
|
|
12
19
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
20
|
/**
|
|
@@ -22,8 +29,51 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
22
29
|
* 记录错误日志
|
|
23
30
|
*/
|
|
24
31
|
private logError;
|
|
32
|
+
private registerDiscountModules;
|
|
33
|
+
private createDefaultRulesHooks;
|
|
34
|
+
loadDiscountConfig(params: {
|
|
35
|
+
customerId: number;
|
|
36
|
+
action?: 'create';
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
getDiscountList(): Discount[];
|
|
39
|
+
scanCode(code: string, customerId?: number): Promise<{
|
|
40
|
+
isAvailable: boolean;
|
|
41
|
+
discountList: Discount[];
|
|
42
|
+
type: 'server' | 'clientCalc';
|
|
43
|
+
unavailableReason?: UnavailableReason;
|
|
44
|
+
}>;
|
|
45
|
+
applyDiscount(): void;
|
|
46
|
+
initTempOrder(params: {
|
|
47
|
+
cacheId?: string;
|
|
48
|
+
salesSummaryModuleName?: string;
|
|
49
|
+
}): void;
|
|
50
|
+
private getTempOrderStorageKey;
|
|
51
|
+
private restoreTempOrderFromStorage;
|
|
52
|
+
persistTempOrder(): void;
|
|
53
|
+
private createDefaultTempOrderInstance;
|
|
54
|
+
ensureTempOrder(): ScanOrderTempOrder;
|
|
55
|
+
getTempOrder(): ScanOrderTempOrder | null;
|
|
56
|
+
addNewOrder(): Promise<ScanOrderTempOrder>;
|
|
57
|
+
getOrderProducts(): ScanOrderOrderProduct[];
|
|
58
|
+
private getSalesSummary;
|
|
59
|
+
recalculateSummary(options?: {
|
|
60
|
+
createIfMissing?: boolean;
|
|
61
|
+
}): Promise<ScanOrderSummary | null>;
|
|
62
|
+
getScanOrderSummary(): Promise<ScanOrderSummary>;
|
|
63
|
+
updateTempOrderNote(note: string): string;
|
|
64
|
+
updateTempOrderContactsInfo(contactsInfo: any[]): any[];
|
|
65
|
+
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
66
|
+
updateProductInOrder(params: {
|
|
67
|
+
product_id: number | null;
|
|
68
|
+
product_variant_id: number;
|
|
69
|
+
updates: Partial<ScanOrderOrderProduct>;
|
|
70
|
+
}): Promise<ScanOrderOrderProduct[]>;
|
|
71
|
+
removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
|
|
72
|
+
submitTempOrder<T = any>(params?: {
|
|
73
|
+
cacheId?: string;
|
|
74
|
+
}): Promise<T>;
|
|
25
75
|
createOrder(params: CommitOrderParams['query']): {
|
|
26
|
-
type: "
|
|
76
|
+
type: "virtual" | "appointment_booking";
|
|
27
77
|
platform: string;
|
|
28
78
|
sales_channel: string;
|
|
29
79
|
order_sales_channel: string;
|
|
@@ -51,4 +101,6 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
51
101
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
52
102
|
*/
|
|
53
103
|
createOrderByCheckout(params: CheckoutOrderParams): Promise<any>;
|
|
104
|
+
submitScanOrder<T = any>(params: SubmitScanOrderParams): Promise<T>;
|
|
105
|
+
scanOrderMore<T = any>(params: ScanOrderMoreParams): Promise<T>;
|
|
54
106
|
}
|