@pisell/pisellos 2.2.147 → 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 +251 -196
- 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 +31 -4
- 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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
+
var promotion_exports = {};
|
|
31
|
+
__export(promotion_exports, {
|
|
32
|
+
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
+
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
+
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
+
default: () => import_adapter2.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
+
var import_evaluator = require("./evaluator");
|
|
40
|
+
var import_adapter = require("./adapter");
|
|
41
|
+
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
+
var import_examples = require("./examples");
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
+
PromotionAdapter,
|
|
47
|
+
PromotionEvaluator,
|
|
48
|
+
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
+
});
|
|
@@ -45,6 +45,7 @@ module.exports = __toCommonJS(cartProduct_exports);
|
|
|
45
45
|
var import_decimal = __toESM(require("decimal.js"));
|
|
46
46
|
var import_utils = require("../../Product/utils");
|
|
47
47
|
var import_utils2 = require("../../../solution/ShopDiscount/utils");
|
|
48
|
+
var import_utils3 = require("../../Summary/utils");
|
|
48
49
|
var toDiscountPayload = (discountItem) => {
|
|
49
50
|
var _a, _b;
|
|
50
51
|
return {
|
|
@@ -92,6 +93,7 @@ var formatProductToCartItem = (params) => {
|
|
|
92
93
|
cartItem.price = product == null ? void 0 : product.price;
|
|
93
94
|
cartItem.num = num;
|
|
94
95
|
cartItem.total = getProductTotalPrice({ product, bundle, options, num, discounts });
|
|
96
|
+
cartItem.totalDifference = getTotalDifference({ product, bundle, discounts });
|
|
95
97
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
96
98
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
97
99
|
product,
|
|
@@ -235,6 +237,18 @@ var getProductTotalPrice = (params) => {
|
|
|
235
237
|
}
|
|
236
238
|
return Math.max(0, price);
|
|
237
239
|
};
|
|
240
|
+
var getTotalDifference = (params) => {
|
|
241
|
+
const { bundle, discounts } = params;
|
|
242
|
+
const bundleDiscountList = [];
|
|
243
|
+
if (bundle == null ? void 0 : bundle.length) {
|
|
244
|
+
bundle.forEach((currentValue) => {
|
|
245
|
+
bundleDiscountList.push(...(currentValue == null ? void 0 : currentValue.discount_list) || []);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
const allDiscounts = [...discounts || [], ...bundleDiscountList];
|
|
249
|
+
const productDiscountProductDiscountDifference = (0, import_utils3.calcDiscountListDifference)(allDiscounts);
|
|
250
|
+
return productDiscountProductDiscountDifference || 0;
|
|
251
|
+
};
|
|
238
252
|
var getProductOriginTotalPrice = (params) => {
|
|
239
253
|
const { product, bundle, options, discounts } = params;
|
|
240
254
|
const num = (params == null ? void 0 : params.num) || 1;
|
|
@@ -299,7 +313,8 @@ var formatBundle = (bundle) => {
|
|
|
299
313
|
options: formatOptions(item == null ? void 0 : item.option),
|
|
300
314
|
_bundle_product_id: item._bundle_product_id,
|
|
301
315
|
discount_list: item.discount_list,
|
|
302
|
-
originBundleItem: item.originBundleItem || item
|
|
316
|
+
originBundleItem: item.originBundleItem || item,
|
|
317
|
+
is_charge_tax: item == null ? void 0 : item.is_charge_tax
|
|
303
318
|
};
|
|
304
319
|
});
|
|
305
320
|
};
|
|
@@ -326,6 +341,7 @@ var formatBundleToOrigin = (bundle) => {
|
|
|
326
341
|
option: formatOptionsToOrigin(getBundleValueByKey("option")),
|
|
327
342
|
discount_list: d.discount_list,
|
|
328
343
|
"bundle_selling_price": d == null ? void 0 : d.price,
|
|
344
|
+
"custom_price": d == null ? void 0 : d.price,
|
|
329
345
|
metadata: {
|
|
330
346
|
custom_product_bundle_map_id: d._id,
|
|
331
347
|
product_discount_difference
|
|
@@ -60,6 +60,11 @@ async function updateAllCartItemPrice(cartItems, priceData, getProduct, updateCa
|
|
|
60
60
|
if (targetBundleItem.price_type === "markdown") {
|
|
61
61
|
targetBundleItem.price = new import_decimal.default(targetBundleItem.price || 0).mul(-1).toNumber();
|
|
62
62
|
}
|
|
63
|
+
if (n.option) {
|
|
64
|
+
targetBundleItem.price = new import_decimal.default(targetBundleItem.price || 0).add(n.option.reduce((pre, cur) => {
|
|
65
|
+
return pre + new import_decimal.default(cur.price || 0).mul(cur.num || 1).toNumber();
|
|
66
|
+
}, 0)).toNumber();
|
|
67
|
+
}
|
|
63
68
|
if (targetBundleItem) {
|
|
64
69
|
return {
|
|
65
70
|
...n,
|
|
@@ -37,5 +37,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
37
37
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
38
38
|
clearDateRange(): void;
|
|
39
39
|
storeChange(): void;
|
|
40
|
-
getResourcesListByDate(date: string): any[]
|
|
40
|
+
getResourcesListByDate(date: string): any[];
|
|
41
41
|
}
|
|
@@ -64,6 +64,12 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
setDateRange(dateRange) {
|
|
67
|
+
dateRange.forEach((item) => {
|
|
68
|
+
var _a;
|
|
69
|
+
if (!((_a = item.resource) == null ? void 0 : _a.length)) {
|
|
70
|
+
item.resource = this.getResourcesListByDate(item.date);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
67
73
|
this.store.dateRange = dateRange;
|
|
68
74
|
}
|
|
69
75
|
getDateRange() {
|
|
@@ -252,7 +258,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
252
258
|
getResourcesListByDate(date) {
|
|
253
259
|
var _a;
|
|
254
260
|
const dateList = this.store.dateList;
|
|
255
|
-
const resourcesList = (_a = dateList.find((item) => item.date === date)) == null ? void 0 : _a.resource;
|
|
261
|
+
const resourcesList = ((_a = dateList == null ? void 0 : dateList.find((item) => item.date === date)) == null ? void 0 : _a.resource) || [];
|
|
256
262
|
return resourcesList;
|
|
257
263
|
}
|
|
258
264
|
};
|
|
@@ -20,7 +20,9 @@ export interface ITime {
|
|
|
20
20
|
date: string;
|
|
21
21
|
week: string;
|
|
22
22
|
weekNum: number;
|
|
23
|
-
status: 'unavailable' | 'available';
|
|
23
|
+
status: 'unavailable' | 'available' | 'lots_of_space' | 'filling_up_fast' | 'sold_out';
|
|
24
|
+
summaryCount?: number;
|
|
25
|
+
availableCount?: number;
|
|
24
26
|
resource?: any[];
|
|
25
27
|
color?: string[];
|
|
26
28
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import type { ScheduleModule } from '../Schedule';
|
|
4
|
+
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult } from './types';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { computeAvailability } from './utils';
|
|
7
|
+
export declare class OpenDataModule extends BaseModule implements Module {
|
|
8
|
+
protected defaultName: string;
|
|
9
|
+
protected defaultVersion: string;
|
|
10
|
+
private request;
|
|
11
|
+
private window;
|
|
12
|
+
private store;
|
|
13
|
+
private cacheId;
|
|
14
|
+
private openCache;
|
|
15
|
+
private fatherModule;
|
|
16
|
+
private otherParams;
|
|
17
|
+
constructor(name?: string, version?: string);
|
|
18
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
|
+
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
20
|
+
getOpenData(): OpenDataConfig | null;
|
|
21
|
+
getLastFetchedAt(): number | null;
|
|
22
|
+
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
23
|
+
storeChange(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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/OpenData/index.ts
|
|
21
|
+
var OpenData_exports = {};
|
|
22
|
+
__export(OpenData_exports, {
|
|
23
|
+
OpenDataModule: () => OpenDataModule,
|
|
24
|
+
computeAvailability: () => import_utils2.computeAvailability
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(OpenData_exports);
|
|
27
|
+
var import_BaseModule = require("../BaseModule");
|
|
28
|
+
var import_utils = require("./utils");
|
|
29
|
+
__reExport(OpenData_exports, require("./types"), module.exports);
|
|
30
|
+
var import_utils2 = require("./utils");
|
|
31
|
+
var OpenDataModule = class extends import_BaseModule.BaseModule {
|
|
32
|
+
constructor(name, version) {
|
|
33
|
+
super(name, version);
|
|
34
|
+
this.defaultName = "openData";
|
|
35
|
+
this.defaultVersion = "1.0.0";
|
|
36
|
+
this.openCache = false;
|
|
37
|
+
this.otherParams = {};
|
|
38
|
+
}
|
|
39
|
+
async initialize(core, options) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
this.core = core;
|
|
42
|
+
this.store = options.store;
|
|
43
|
+
this.store.data = ((_a = options.initialState) == null ? void 0 : _a.data) ?? null;
|
|
44
|
+
this.store.lastFetchedAt = ((_b = options.initialState) == null ? void 0 : _b.lastFetchedAt) ?? null;
|
|
45
|
+
this.otherParams = options.otherParams || {};
|
|
46
|
+
if (this.otherParams.cacheId) {
|
|
47
|
+
this.openCache = this.otherParams.openCache ?? false;
|
|
48
|
+
this.cacheId = this.otherParams.cacheId;
|
|
49
|
+
}
|
|
50
|
+
if (this.otherParams.fatherModule) {
|
|
51
|
+
this.fatherModule = this.otherParams.fatherModule;
|
|
52
|
+
}
|
|
53
|
+
this.request = core.getPlugin("request");
|
|
54
|
+
this.window = core.getPlugin("window");
|
|
55
|
+
if (!this.request)
|
|
56
|
+
throw new Error("OpenDataModule 需要 request 插件支持");
|
|
57
|
+
if (!this.window)
|
|
58
|
+
throw new Error("OpenDataModule 需要 window 插件支持");
|
|
59
|
+
console.log("[OpenDataModule] 初始化完成");
|
|
60
|
+
}
|
|
61
|
+
async fetchOpenData(params) {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
const shopId = (_b = (_a = this.otherParams) == null ? void 0 : _a.getStateData) == null ? void 0 : _b.call(_a, "shop_id");
|
|
64
|
+
if (!shopId)
|
|
65
|
+
throw new Error("[OpenDataModule] 无法获取 shop_id");
|
|
66
|
+
const tenantId = (_d = (_c = this.otherParams) == null ? void 0 : _c.getStateData) == null ? void 0 : _d.call(_c, "tenant_id");
|
|
67
|
+
const headers = {};
|
|
68
|
+
if (tenantId)
|
|
69
|
+
headers["Tenant-Id"] = String(tenantId);
|
|
70
|
+
const response = await this.request.post(
|
|
71
|
+
`/open/my-pisell/${shopId}/setting`,
|
|
72
|
+
{
|
|
73
|
+
scope: params.scope,
|
|
74
|
+
target: params.target,
|
|
75
|
+
section_code: params.section_code
|
|
76
|
+
},
|
|
77
|
+
{ pisell2: true, headers }
|
|
78
|
+
);
|
|
79
|
+
if ((response == null ? void 0 : response.status) === false) {
|
|
80
|
+
throw new Error((response == null ? void 0 : response.message) || "获取 OpenData 配置失败");
|
|
81
|
+
}
|
|
82
|
+
const data = (response == null ? void 0 : response.data) || {};
|
|
83
|
+
this.store.data = data;
|
|
84
|
+
this.store.lastFetchedAt = Date.now();
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
getOpenData() {
|
|
88
|
+
return this.store.data;
|
|
89
|
+
}
|
|
90
|
+
getLastFetchedAt() {
|
|
91
|
+
return this.store.lastFetchedAt ?? null;
|
|
92
|
+
}
|
|
93
|
+
checkAvailability(scheduleModule) {
|
|
94
|
+
var _a;
|
|
95
|
+
const scheduleList = scheduleModule ? scheduleModule.getScheduleListByIds(
|
|
96
|
+
((_a = this.store.data) == null ? void 0 : _a["availability.operating_hours"]) || []
|
|
97
|
+
) : void 0;
|
|
98
|
+
return (0, import_utils.computeAvailability)({
|
|
99
|
+
config: this.store.data,
|
|
100
|
+
scheduleList
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
storeChange() {
|
|
104
|
+
if (this.openCache) {
|
|
105
|
+
this.checkSaveCache({
|
|
106
|
+
cacheId: this.cacheId,
|
|
107
|
+
fatherModule: this.fatherModule,
|
|
108
|
+
store: this.store,
|
|
109
|
+
cacheKey: ["data", "lastFetchedAt"]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
OpenDataModule,
|
|
117
|
+
computeAvailability,
|
|
118
|
+
...require("./types")
|
|
119
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
2
|
+
export interface MultiLangObject {
|
|
3
|
+
en?: string;
|
|
4
|
+
ja?: string;
|
|
5
|
+
pt?: string;
|
|
6
|
+
'zh-CN'?: string;
|
|
7
|
+
'zh-HK'?: string;
|
|
8
|
+
original?: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface OpenDataConfig {
|
|
12
|
+
'basic.enable'?: boolean;
|
|
13
|
+
'basic.code'?: string | null;
|
|
14
|
+
'basic.name'?: string | MultiLangObject;
|
|
15
|
+
'basic.unavailable_message'?: string | MultiLangObject;
|
|
16
|
+
'availability.paused'?: boolean;
|
|
17
|
+
'availability.pause_message'?: string | MultiLangObject;
|
|
18
|
+
'availability.pause_behavior'?: string;
|
|
19
|
+
'availability.closed_behavior'?: string;
|
|
20
|
+
'availability.closed_message'?: string | MultiLangObject;
|
|
21
|
+
'availability.operating_hours'?: number[];
|
|
22
|
+
'reservation.enable'?: boolean;
|
|
23
|
+
'reservation.auto_confirm'?: boolean;
|
|
24
|
+
'reservation.auto_confirm_mode'?: string;
|
|
25
|
+
'reservation.auto_confirm_delay_seconds'?: number;
|
|
26
|
+
'sale.allow_item_notes'?: boolean;
|
|
27
|
+
'sale.allow_order_notes'?: boolean;
|
|
28
|
+
'sale.enable_item_rules'?: boolean;
|
|
29
|
+
'sale.enable_short_number'?: boolean;
|
|
30
|
+
'sale.short_number_daily_reset'?: boolean;
|
|
31
|
+
'sale.short_number_start_number'?: number;
|
|
32
|
+
'sale.short_number_prefix'?: string | null;
|
|
33
|
+
'sale.sale_number_prefix'?: string | null;
|
|
34
|
+
'sale.enabled_item_rules'?: number[];
|
|
35
|
+
'fulfillment.enable_pickup'?: boolean;
|
|
36
|
+
'fulfillment.overdue_reminder'?: boolean;
|
|
37
|
+
'fulfillment.manual_input_type'?: string;
|
|
38
|
+
'fulfillment.enable_auto_complete'?: boolean;
|
|
39
|
+
'fulfillment.enable_table_service'?: boolean;
|
|
40
|
+
'fulfillment.fulfillment_ref_mode'?: string;
|
|
41
|
+
'fulfillment.advance_warning_minutes'?: number;
|
|
42
|
+
'fulfillment.update_end_time_on_auto_complete'?: string;
|
|
43
|
+
'menu.associated_menus'?: Array<{
|
|
44
|
+
label: string;
|
|
45
|
+
value: number;
|
|
46
|
+
}>;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
export interface OpenDataState {
|
|
50
|
+
data: OpenDataConfig | null;
|
|
51
|
+
lastFetchedAt: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface OpenDataFetchParams {
|
|
54
|
+
scope: string;
|
|
55
|
+
target: string;
|
|
56
|
+
section_code: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface OpenDataApiResponse {
|
|
59
|
+
status: boolean;
|
|
60
|
+
code: number;
|
|
61
|
+
message: string;
|
|
62
|
+
data: OpenDataConfig;
|
|
63
|
+
}
|
|
64
|
+
export type OpenDataUnavailableReason = 'shop_disabled' | 'paused' | 'closed' | 'reservation_disabled';
|
|
65
|
+
export interface OpenDataAvailabilityResult {
|
|
66
|
+
available: boolean;
|
|
67
|
+
reason: OpenDataUnavailableReason | null;
|
|
68
|
+
message: string | MultiLangObject | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ComputeAvailabilityParams {
|
|
71
|
+
config: OpenDataConfig | null;
|
|
72
|
+
scheduleList?: ScheduleItem[];
|
|
73
|
+
}
|
|
@@ -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/OpenData/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/modules/OpenData/utils.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
computeAvailability: () => computeAvailability
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utils_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
|
|
37
|
+
function toBoolean(value) {
|
|
38
|
+
if (typeof value === "boolean")
|
|
39
|
+
return value;
|
|
40
|
+
if (typeof value === "string")
|
|
41
|
+
return value === "true" || value === "1";
|
|
42
|
+
if (typeof value === "number")
|
|
43
|
+
return value !== 0;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function resolveMessage(...candidates) {
|
|
47
|
+
for (const val of candidates) {
|
|
48
|
+
if (!val)
|
|
49
|
+
continue;
|
|
50
|
+
if (typeof val === "string" && val.length > 0)
|
|
51
|
+
return val;
|
|
52
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val))
|
|
53
|
+
return val;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function computeAvailability(params) {
|
|
58
|
+
const { config, scheduleList } = params;
|
|
59
|
+
if (!config) {
|
|
60
|
+
return { available: true, reason: null, message: null };
|
|
61
|
+
}
|
|
62
|
+
if (config["basic.enable"] === false) {
|
|
63
|
+
return {
|
|
64
|
+
available: false,
|
|
65
|
+
reason: "shop_disabled",
|
|
66
|
+
message: resolveMessage(
|
|
67
|
+
config["basic.unavailable_message"],
|
|
68
|
+
config["availability.closed_message"]
|
|
69
|
+
)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (toBoolean(config["availability.paused"])) {
|
|
73
|
+
return {
|
|
74
|
+
available: false,
|
|
75
|
+
reason: "paused",
|
|
76
|
+
message: resolveMessage(
|
|
77
|
+
config["availability.pause_message"],
|
|
78
|
+
config["availability.closed_message"]
|
|
79
|
+
)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const operatingHourIds = config["availability.operating_hours"];
|
|
83
|
+
if (Array.isArray(operatingHourIds) && operatingHourIds.length > 0 && (scheduleList == null ? void 0 : scheduleList.length)) {
|
|
84
|
+
const relevantSchedules = scheduleList.filter(
|
|
85
|
+
(s) => operatingHourIds.includes(s.id)
|
|
86
|
+
);
|
|
87
|
+
if (relevantSchedules.length > 0) {
|
|
88
|
+
const now = (0, import_dayjs.default)().format("YYYY-MM-DD HH:mm:ss");
|
|
89
|
+
const isOpen = (0, import_getDateIsInSchedule.getDateIsInSchedule)(now, relevantSchedules);
|
|
90
|
+
if (!isOpen) {
|
|
91
|
+
return {
|
|
92
|
+
available: false,
|
|
93
|
+
reason: "closed",
|
|
94
|
+
message: resolveMessage(config["availability.closed_message"])
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (config["reservation.enable"] === false) {
|
|
100
|
+
return {
|
|
101
|
+
available: false,
|
|
102
|
+
reason: "reservation_disabled",
|
|
103
|
+
message: resolveMessage(config["availability.closed_message"])
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return { available: true, reason: null, message: null };
|
|
107
|
+
}
|
|
108
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
+
0 && (module.exports = {
|
|
110
|
+
computeAvailability
|
|
111
|
+
});
|