@pisell/pisellos 2.2.148 → 2.2.149
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 +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -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 +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -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 +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -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 +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -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 +203 -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 +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +246 -193
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -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 +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -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 +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -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 +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -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 +148 -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 +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +26 -1
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -43,6 +43,8 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
43
43
|
const query = {};
|
|
44
44
|
if (params == null ? void 0 : params.channel)
|
|
45
45
|
query.channel = params.channel;
|
|
46
|
+
if (params == null ? void 0 : params.customer_id)
|
|
47
|
+
query.customer_id = String(params.customer_id);
|
|
46
48
|
if ((params == null ? void 0 : params.channel) === "online_store") {
|
|
47
49
|
query.channel = "online-store";
|
|
48
50
|
}
|
|
@@ -51,7 +53,10 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
51
53
|
query,
|
|
52
54
|
{ useCache: false }
|
|
53
55
|
);
|
|
54
|
-
const list =
|
|
56
|
+
const list = this.filterQuotationsByCustomer(
|
|
57
|
+
((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [],
|
|
58
|
+
params == null ? void 0 : params.customer_id
|
|
59
|
+
);
|
|
55
60
|
list.sort((a, b) => a.sort - b.sort);
|
|
56
61
|
this.store.list = list;
|
|
57
62
|
}
|
|
@@ -67,8 +72,10 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
67
72
|
* the requested productId wins.
|
|
68
73
|
*/
|
|
69
74
|
getPriceForProduct(params) {
|
|
70
|
-
const { productId, variantId, datetime } = params;
|
|
75
|
+
const { productId, variantId, datetime, customer_id } = params;
|
|
71
76
|
for (const quotation of this.store.list) {
|
|
77
|
+
if (!this.isQuotationVisibleForCustomer(quotation, customer_id))
|
|
78
|
+
continue;
|
|
72
79
|
if (!this.isQuotationActiveAt(quotation, datetime))
|
|
73
80
|
continue;
|
|
74
81
|
const match = this.findProductData(quotation.product_data, productId, variantId);
|
|
@@ -81,8 +88,10 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
81
88
|
return null;
|
|
82
89
|
}
|
|
83
90
|
getQuotationShelfId(params) {
|
|
84
|
-
const { productId, variantId, datetime } = params;
|
|
91
|
+
const { productId, variantId, datetime, customer_id } = params;
|
|
85
92
|
for (const quotation of this.store.list) {
|
|
93
|
+
if (!this.isQuotationVisibleForCustomer(quotation, customer_id))
|
|
94
|
+
continue;
|
|
86
95
|
if (!this.isQuotationActiveAt(quotation, datetime))
|
|
87
96
|
continue;
|
|
88
97
|
const match = this.findProductData(quotation.product_data, productId, variantId);
|
|
@@ -104,7 +113,11 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
104
113
|
for (const productId of params.productIds) {
|
|
105
114
|
for (const timePoint of params.timePoints) {
|
|
106
115
|
const key = `${productId}:${timePoint}`;
|
|
107
|
-
const price = this.getPriceForProduct({
|
|
116
|
+
const price = this.getPriceForProduct({
|
|
117
|
+
productId,
|
|
118
|
+
datetime: timePoint,
|
|
119
|
+
customer_id: params.customer_id
|
|
120
|
+
});
|
|
108
121
|
if (price !== null) {
|
|
109
122
|
map.set(key, price);
|
|
110
123
|
}
|
|
@@ -115,6 +128,22 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
|
|
|
115
128
|
setScheduleResolver(resolver) {
|
|
116
129
|
this.scheduleResolver = resolver;
|
|
117
130
|
}
|
|
131
|
+
filterQuotationsByCustomer(list, customerId) {
|
|
132
|
+
return list.filter((quotation) => this.isQuotationVisibleForCustomer(quotation, customerId));
|
|
133
|
+
}
|
|
134
|
+
isQuotationVisibleForCustomer(quotation, customerId) {
|
|
135
|
+
const customers = quotation.customer || [];
|
|
136
|
+
if (customers.length === 0)
|
|
137
|
+
return true;
|
|
138
|
+
if (!this.hasValidCustomerId(customerId))
|
|
139
|
+
return false;
|
|
140
|
+
return customers.some((customer) => String(customer.id) === String(customerId));
|
|
141
|
+
}
|
|
142
|
+
hasValidCustomerId(customerId) {
|
|
143
|
+
if (customerId === void 0 || customerId === null || customerId === "")
|
|
144
|
+
return false;
|
|
145
|
+
return Number(customerId) > 0;
|
|
146
|
+
}
|
|
118
147
|
isQuotationActiveAt(quotation, datetime) {
|
|
119
148
|
var _a;
|
|
120
149
|
if (!((_a = quotation.schedule) == null ? void 0 : _a.length))
|
|
@@ -22,6 +22,10 @@ export interface QuotationSchedule {
|
|
|
22
22
|
}>;
|
|
23
23
|
pivot?: Record<string, any>;
|
|
24
24
|
}
|
|
25
|
+
export interface QuotationCustomer {
|
|
26
|
+
id: number | string;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
25
29
|
export interface QuotationItem {
|
|
26
30
|
id: number;
|
|
27
31
|
shop_id: number;
|
|
@@ -34,6 +38,7 @@ export interface QuotationItem {
|
|
|
34
38
|
created_at?: string;
|
|
35
39
|
updated_at?: string;
|
|
36
40
|
deleted_at?: string | null;
|
|
41
|
+
customer?: QuotationCustomer[];
|
|
37
42
|
schedule: QuotationSchedule[];
|
|
38
43
|
product_data: QuotationProductData[];
|
|
39
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { Rules, RulesModuleAPI, DiscountResult } from './types';
|
|
3
|
+
import { Rules, RulesModuleAPI, DiscountResult, UnavailableReason } from './types';
|
|
4
4
|
import { Discount } from '../Discount/types';
|
|
5
5
|
import { SetDiscountSelectedParams } from '../../solution/ShopDiscount/types';
|
|
6
6
|
import { WindowPlugin } from '../../plugins';
|
|
@@ -29,8 +29,10 @@ export declare class RulesModule extends BaseModule implements Module, RulesModu
|
|
|
29
29
|
isAvailable: boolean;
|
|
30
30
|
discountList: Discount[];
|
|
31
31
|
productList: any[];
|
|
32
|
+
unavailableReason?: UnavailableReason;
|
|
32
33
|
};
|
|
33
34
|
filterDiscountListByType(discountList: Discount[], type: string): Discount[];
|
|
35
|
+
private getUnavailableReason;
|
|
34
36
|
calcDiscount({ discountList, productList, holders, isFormSubject, orderTotalAmount }: {
|
|
35
37
|
discountList: Discount[];
|
|
36
38
|
productList: any[];
|
|
@@ -33,6 +33,7 @@ __export(Rules_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Rules_exports);
|
|
35
35
|
var import_BaseModule = require("../BaseModule");
|
|
36
|
+
var import_types = require("./types");
|
|
36
37
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
37
38
|
var import_utils2 = require("../Cart/utils");
|
|
38
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
@@ -101,7 +102,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
101
102
|
return {
|
|
102
103
|
isAvailable: false,
|
|
103
104
|
discountList: oldDiscountList,
|
|
104
|
-
productList
|
|
105
|
+
productList,
|
|
106
|
+
unavailableReason: import_types.UnavailableReason.AlreadyUsed
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
109
|
const filteredOldDiscountList = oldDiscountList.filter(
|
|
@@ -143,15 +145,52 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
});
|
|
148
|
+
let unavailableReason;
|
|
149
|
+
if (!hasApplicableDiscount) {
|
|
150
|
+
unavailableReason = this.getUnavailableReason(newDiscountList, productList);
|
|
151
|
+
}
|
|
146
152
|
return {
|
|
147
153
|
isAvailable: hasApplicableDiscount,
|
|
148
154
|
discountList: hasApplicableDiscount ? result.discountList : oldDiscountList,
|
|
149
|
-
productList: hasApplicableDiscount ? result.productList : productList
|
|
155
|
+
productList: hasApplicableDiscount ? result.productList : productList,
|
|
156
|
+
unavailableReason
|
|
150
157
|
};
|
|
151
158
|
}
|
|
152
159
|
filterDiscountListByType(discountList, type) {
|
|
153
160
|
return (discountList || []).filter((item) => item.type === type || item.tag === type);
|
|
154
161
|
}
|
|
162
|
+
// 获取券不可用的原因
|
|
163
|
+
getUnavailableReason(discountList, productList) {
|
|
164
|
+
var _a;
|
|
165
|
+
for (const discount of discountList) {
|
|
166
|
+
for (const item of productList) {
|
|
167
|
+
const product = this.hooks.getProduct(item);
|
|
168
|
+
const bookingTime = ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss");
|
|
169
|
+
const filteredList = (0, import_utils.filterDiscountListByBookingTime)([discount], bookingTime);
|
|
170
|
+
if (filteredList.length === 0) {
|
|
171
|
+
return import_types.UnavailableReason.TimeLimit;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
for (const discount of discountList) {
|
|
176
|
+
const limitedData = discount.limited_relation_product_data;
|
|
177
|
+
let hasApplicableProduct = false;
|
|
178
|
+
for (const item of productList) {
|
|
179
|
+
const product = this.hooks.getProduct(item);
|
|
180
|
+
if (limitedData.type === "product_all") {
|
|
181
|
+
hasApplicableProduct = true;
|
|
182
|
+
break;
|
|
183
|
+
} else if ((_a = limitedData.product_ids) == null ? void 0 : _a.includes(product.id)) {
|
|
184
|
+
hasApplicableProduct = true;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (!hasApplicableProduct) {
|
|
189
|
+
return import_types.UnavailableReason.ProductNotApplicable;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return import_types.UnavailableReason.Unknown;
|
|
193
|
+
}
|
|
155
194
|
calcDiscount({
|
|
156
195
|
discountList,
|
|
157
196
|
productList,
|
|
@@ -475,7 +514,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
475
514
|
}
|
|
476
515
|
const applicableProducts = [];
|
|
477
516
|
sortedFlattenedList.forEach((flatItem) => {
|
|
478
|
-
var _a, _b;
|
|
517
|
+
var _a, _b, _c;
|
|
479
518
|
const occupyingDiscountId = occupiedItems.get(flatItem._id);
|
|
480
519
|
if (occupyingDiscountId !== void 0 && occupyingDiscountId !== discount.id) {
|
|
481
520
|
return;
|
|
@@ -495,14 +534,15 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
495
534
|
num: flatItem.num
|
|
496
535
|
};
|
|
497
536
|
}
|
|
498
|
-
const quantity = flatItem.type === "main" ? product.quantity || 1 : (product.num || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.quantity) || 1);
|
|
537
|
+
const quantity = flatItem.type === "main" ? product.num || product.quantity || 1 : (product.num || product.quantity || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.num) || ((_b = flatItem.parentProduct) == null ? void 0 : _b.quantity) || 1);
|
|
538
|
+
const originalAmount = flatItem.type === "main" ? Number(product.price ?? 0) : Number(flatItem.original_price ?? flatItem.price ?? 0);
|
|
499
539
|
const productData = {
|
|
500
540
|
productId: flatItem._id,
|
|
501
|
-
amount:
|
|
541
|
+
amount: originalAmount,
|
|
502
542
|
quantity
|
|
503
543
|
};
|
|
504
544
|
if (flatItem.type === "bundle") {
|
|
505
|
-
productData.parentQuantity = ((
|
|
545
|
+
productData.parentQuantity = ((_c = flatItem.parentProduct) == null ? void 0 : _c.quantity) || 1;
|
|
506
546
|
}
|
|
507
547
|
applicableProducts.push(productData);
|
|
508
548
|
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { Discount } from '../Discount/types';
|
|
2
|
+
export declare enum UnavailableReason {
|
|
3
|
+
TimeLimit = "time_limit",
|
|
4
|
+
ProductNotApplicable = "product_not_applicable",
|
|
5
|
+
AlreadyUsed = "already_used",
|
|
6
|
+
Unknown = "unknown"
|
|
7
|
+
}
|
|
2
8
|
export declare enum RulesHooks {
|
|
3
9
|
OnRulesListChange = "rules:onRulesListChange",
|
|
4
10
|
OnDestroy = "rules:onDestroy"
|
|
@@ -19,9 +19,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/modules/Rules/types.ts
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
|
-
RulesHooks: () => RulesHooks
|
|
22
|
+
RulesHooks: () => RulesHooks,
|
|
23
|
+
UnavailableReason: () => UnavailableReason
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(types_exports);
|
|
26
|
+
var UnavailableReason = /* @__PURE__ */ ((UnavailableReason2) => {
|
|
27
|
+
UnavailableReason2["TimeLimit"] = "time_limit";
|
|
28
|
+
UnavailableReason2["ProductNotApplicable"] = "product_not_applicable";
|
|
29
|
+
UnavailableReason2["AlreadyUsed"] = "already_used";
|
|
30
|
+
UnavailableReason2["Unknown"] = "unknown";
|
|
31
|
+
return UnavailableReason2;
|
|
32
|
+
})(UnavailableReason || {});
|
|
25
33
|
var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
26
34
|
RulesHooks2["OnRulesListChange"] = "rules:onRulesListChange";
|
|
27
35
|
RulesHooks2["OnDestroy"] = "rules:onDestroy";
|
|
@@ -29,5 +37,6 @@ var RulesHooks = /* @__PURE__ */ ((RulesHooks2) => {
|
|
|
29
37
|
})(RulesHooks || {});
|
|
30
38
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
39
|
0 && (module.exports = {
|
|
32
|
-
RulesHooks
|
|
40
|
+
RulesHooks,
|
|
41
|
+
UnavailableReason
|
|
33
42
|
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { SalesSummaryModuleAPI } from './types';
|
|
4
|
+
export * from './types';
|
|
5
|
+
export declare class SalesSummaryModule extends BaseModule implements Module, SalesSummaryModuleAPI {
|
|
6
|
+
protected defaultName: string;
|
|
7
|
+
protected defaultVersion: string;
|
|
8
|
+
private shopStore;
|
|
9
|
+
private store;
|
|
10
|
+
private request;
|
|
11
|
+
constructor(name?: string, version?: string);
|
|
12
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
+
getSurchargeList(): Promise<void>;
|
|
14
|
+
getSummary(params: {
|
|
15
|
+
products: any[];
|
|
16
|
+
isPriceIncludeTax?: number;
|
|
17
|
+
taxRate?: number;
|
|
18
|
+
shopDiscount?: string | number;
|
|
19
|
+
}): Promise<{
|
|
20
|
+
tax_title: any;
|
|
21
|
+
tax_rate: any;
|
|
22
|
+
product_quantity: number;
|
|
23
|
+
product_original_amount: string;
|
|
24
|
+
product_amount: string;
|
|
25
|
+
product_expect_amount: string;
|
|
26
|
+
product_tax_fee: string;
|
|
27
|
+
shipping_fee: string;
|
|
28
|
+
shipping_tax_fee: string;
|
|
29
|
+
tax_fee: string;
|
|
30
|
+
surcharge_fee: string;
|
|
31
|
+
surcharges: any[];
|
|
32
|
+
discount_amount: string;
|
|
33
|
+
deposit_amount: string;
|
|
34
|
+
deposit?: import("./types").DepositInfo | undefined;
|
|
35
|
+
expect_amount: string;
|
|
36
|
+
total_amount: string;
|
|
37
|
+
total_refund_amount: string;
|
|
38
|
+
customer_paid_amount: string;
|
|
39
|
+
order_paid_amount: string;
|
|
40
|
+
amount_gap: string;
|
|
41
|
+
rounding_amount: string;
|
|
42
|
+
pay_service_charge_amount: string;
|
|
43
|
+
is_price_include_tax?: number | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
tax_title: any;
|
|
46
|
+
tax_rate: any;
|
|
47
|
+
product_quantity: number;
|
|
48
|
+
product_original_amount: string;
|
|
49
|
+
product_amount: string;
|
|
50
|
+
product_expect_amount: string;
|
|
51
|
+
product_tax_fee: string;
|
|
52
|
+
shipping_fee: string;
|
|
53
|
+
shipping_tax_fee: string;
|
|
54
|
+
tax_fee: string;
|
|
55
|
+
surcharge_fee: string;
|
|
56
|
+
surcharges: any;
|
|
57
|
+
discount_amount: string;
|
|
58
|
+
deposit_amount: string;
|
|
59
|
+
deposit: import("./types").DepositInfo | undefined;
|
|
60
|
+
expect_amount: string;
|
|
61
|
+
total_amount: string;
|
|
62
|
+
total_refund_amount: string;
|
|
63
|
+
customer_paid_amount: string;
|
|
64
|
+
order_paid_amount: string;
|
|
65
|
+
amount_gap: string;
|
|
66
|
+
rounding_amount: string;
|
|
67
|
+
pay_service_charge_amount: string;
|
|
68
|
+
is_price_include_tax: number;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/modules/SalesSummary/index.ts
|
|
21
|
+
var SalesSummary_exports = {};
|
|
22
|
+
__export(SalesSummary_exports, {
|
|
23
|
+
SalesSummaryModule: () => SalesSummaryModule
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(SalesSummary_exports);
|
|
26
|
+
var import_BaseModule = require("../BaseModule");
|
|
27
|
+
var import_Schedule = require("../Schedule");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
__reExport(SalesSummary_exports, require("./types"), module.exports);
|
|
30
|
+
var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
31
|
+
constructor(name, version) {
|
|
32
|
+
super(name, version);
|
|
33
|
+
this.defaultName = "salesSummary";
|
|
34
|
+
this.defaultVersion = "1.0.0";
|
|
35
|
+
}
|
|
36
|
+
async initialize(core, options) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
this.core = core;
|
|
39
|
+
this.store = options.store;
|
|
40
|
+
this.shopStore = this.core.getPlugin("shopStore");
|
|
41
|
+
this.request = this.core.getPlugin("request");
|
|
42
|
+
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
43
|
+
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
44
|
+
if (!this.shopStore) {
|
|
45
|
+
throw new Error("SalesSummaryModule 需要 shopStore 插件支持");
|
|
46
|
+
}
|
|
47
|
+
if (!this.request) {
|
|
48
|
+
throw new Error("SalesSummaryModule 需要 request 插件支持");
|
|
49
|
+
}
|
|
50
|
+
await this.getSurchargeList();
|
|
51
|
+
}
|
|
52
|
+
async getSurchargeList() {
|
|
53
|
+
try {
|
|
54
|
+
const surchargeList = await this.request.get(
|
|
55
|
+
"/order/custom-surcharge/available/v2",
|
|
56
|
+
{
|
|
57
|
+
channel: "online-store",
|
|
58
|
+
is_assemble_product_data: 1,
|
|
59
|
+
is_assemble_schedule_data: 1,
|
|
60
|
+
with: ["relationSchedule"]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
|
|
66
|
+
this.store.surchargeList = [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async getSummary(params) {
|
|
70
|
+
var _a, _b;
|
|
71
|
+
const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
|
|
72
|
+
const shopInfo = ((_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.shop) || {};
|
|
73
|
+
const summarySchedule = this.core.getModule(
|
|
74
|
+
`${this.name.split("_")[0]}_schedule`
|
|
75
|
+
);
|
|
76
|
+
const needScheduleIds = this.store.surchargeList.map((item) => item.available_schedule_ids).flat();
|
|
77
|
+
const scheduleList = summarySchedule == null ? void 0 : summarySchedule.getScheduleListByIds(needScheduleIds);
|
|
78
|
+
const scheduleById = {};
|
|
79
|
+
if (Array.isArray(scheduleList)) {
|
|
80
|
+
for (const item of scheduleList) {
|
|
81
|
+
scheduleById[item.id] = item;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const summary = (0, import_utils.calculateSalesSummary)({
|
|
85
|
+
products,
|
|
86
|
+
isPriceIncludeTax: isPriceIncludeTax ?? (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ?? 1,
|
|
87
|
+
taxRate: taxRate ?? (shopInfo == null ? void 0 : shopInfo.tax_rate),
|
|
88
|
+
surchargeList: this.store.surchargeList,
|
|
89
|
+
scheduleById,
|
|
90
|
+
isInScheduleByDate: import_Schedule.ScheduleModule.isInScheduleByDate,
|
|
91
|
+
shopDiscount
|
|
92
|
+
});
|
|
93
|
+
const summaryWithTaxMeta = {
|
|
94
|
+
...summary,
|
|
95
|
+
tax_title: (shopInfo == null ? void 0 : shopInfo.tax_title) || "",
|
|
96
|
+
tax_rate: taxRate ?? (shopInfo == null ? void 0 : shopInfo.tax_rate)
|
|
97
|
+
};
|
|
98
|
+
this.store.summary = summaryWithTaxMeta;
|
|
99
|
+
return summaryWithTaxMeta;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
SalesSummaryModule,
|
|
105
|
+
...require("./types")
|
|
106
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface SalesSummaryProduct {
|
|
2
|
+
product_id: number | null;
|
|
3
|
+
product_variant_id: number;
|
|
4
|
+
num: number;
|
|
5
|
+
/** 券后单品单价(订单域成交单价),由 OrderModule 维护。 */
|
|
6
|
+
selling_price: string;
|
|
7
|
+
/** 券前单品单价(店铺售价)。 */
|
|
8
|
+
original_price: string;
|
|
9
|
+
tax_fee: string;
|
|
10
|
+
is_charge_tax?: number;
|
|
11
|
+
product_option_item?: any[];
|
|
12
|
+
discount_list?: any[];
|
|
13
|
+
product_bundle?: any[];
|
|
14
|
+
metadata?: Record<string, any>;
|
|
15
|
+
_origin?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
export interface DepositPolicyData {
|
|
18
|
+
id: number;
|
|
19
|
+
title: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DepositInfo {
|
|
22
|
+
total: string;
|
|
23
|
+
deposit_policy_ids: number[];
|
|
24
|
+
deposit_policy_data: DepositPolicyData[];
|
|
25
|
+
hasDeposit: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface SalesSummaryData {
|
|
28
|
+
product_quantity: number;
|
|
29
|
+
product_original_amount: string;
|
|
30
|
+
product_amount: string;
|
|
31
|
+
product_expect_amount: string;
|
|
32
|
+
product_tax_fee: string;
|
|
33
|
+
shipping_fee: string;
|
|
34
|
+
shipping_tax_fee: string;
|
|
35
|
+
tax_fee: string;
|
|
36
|
+
surcharge_fee: string;
|
|
37
|
+
surcharges: any[];
|
|
38
|
+
discount_amount: string;
|
|
39
|
+
deposit_amount: string;
|
|
40
|
+
deposit?: DepositInfo;
|
|
41
|
+
expect_amount: string;
|
|
42
|
+
total_amount: string;
|
|
43
|
+
total_refund_amount: string;
|
|
44
|
+
customer_paid_amount: string;
|
|
45
|
+
order_paid_amount: string;
|
|
46
|
+
amount_gap: string;
|
|
47
|
+
rounding_amount: string;
|
|
48
|
+
pay_service_charge_amount: string;
|
|
49
|
+
is_price_include_tax?: number;
|
|
50
|
+
tax_title?: string;
|
|
51
|
+
tax_rate?: number;
|
|
52
|
+
}
|
|
53
|
+
export interface SalesSummaryState {
|
|
54
|
+
surchargeList: any[];
|
|
55
|
+
summary: SalesSummaryData;
|
|
56
|
+
}
|
|
57
|
+
export interface SalesSummaryModuleAPI {
|
|
58
|
+
getSummary(params: {
|
|
59
|
+
products: SalesSummaryProduct[];
|
|
60
|
+
isPriceIncludeTax?: number;
|
|
61
|
+
taxRate?: number;
|
|
62
|
+
shopDiscount?: string | number;
|
|
63
|
+
}): Promise<SalesSummaryData>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/modules/SalesSummary/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DepositInfo, SalesSummaryData, SalesSummaryProduct } from './types';
|
|
2
|
+
export declare function createEmptySalesSummary(): SalesSummaryData;
|
|
3
|
+
export declare function calculateSalesSummary(params: {
|
|
4
|
+
products: SalesSummaryProduct[];
|
|
5
|
+
isPriceIncludeTax: number;
|
|
6
|
+
taxRate?: number;
|
|
7
|
+
surchargeList: any[];
|
|
8
|
+
scheduleById?: Record<string, any>;
|
|
9
|
+
isInScheduleByDate?: any;
|
|
10
|
+
shopDiscount?: string | number;
|
|
11
|
+
}): SalesSummaryData | {
|
|
12
|
+
product_quantity: number;
|
|
13
|
+
product_original_amount: string;
|
|
14
|
+
product_amount: string;
|
|
15
|
+
product_expect_amount: string;
|
|
16
|
+
product_tax_fee: string;
|
|
17
|
+
shipping_fee: string;
|
|
18
|
+
shipping_tax_fee: string;
|
|
19
|
+
tax_fee: string;
|
|
20
|
+
surcharge_fee: string;
|
|
21
|
+
surcharges: any;
|
|
22
|
+
discount_amount: string;
|
|
23
|
+
deposit_amount: string;
|
|
24
|
+
deposit: DepositInfo | undefined;
|
|
25
|
+
expect_amount: string;
|
|
26
|
+
total_amount: string;
|
|
27
|
+
total_refund_amount: string;
|
|
28
|
+
customer_paid_amount: string;
|
|
29
|
+
order_paid_amount: string;
|
|
30
|
+
amount_gap: string;
|
|
31
|
+
rounding_amount: string;
|
|
32
|
+
pay_service_charge_amount: string;
|
|
33
|
+
is_price_include_tax: number;
|
|
34
|
+
};
|