@pisell/pisellos 2.1.171 → 2.1.172

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.
Files changed (230) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +1 -3
  3. package/dist/model/strategy/adapter/index.d.ts +0 -4
  4. package/dist/model/strategy/adapter/index.js +1 -5
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +99 -26
  6. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  7. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  8. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  9. package/dist/model/strategy/engine.d.ts +18 -5
  10. package/dist/model/strategy/engine.js +145 -45
  11. package/dist/model/strategy/type.d.ts +17 -0
  12. package/dist/model/strategy/type.js +4 -0
  13. package/dist/modules/Cart/types.d.ts +2 -0
  14. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  15. package/dist/modules/Cart/utils/changePrice.js +9 -16
  16. package/dist/modules/Discount/index.d.ts +4 -13
  17. package/dist/modules/Discount/index.js +12 -124
  18. package/dist/modules/Discount/types.d.ts +18 -13
  19. package/dist/modules/Order/index.d.ts +1 -67
  20. package/dist/modules/Order/index.js +30 -918
  21. package/dist/modules/Order/types.d.ts +12 -176
  22. package/dist/modules/Order/types.js +0 -2
  23. package/dist/modules/Order/utils.d.ts +0 -118
  24. package/dist/modules/Order/utils.js +2 -586
  25. package/dist/modules/Payment/index.d.ts +2 -1
  26. package/dist/modules/Payment/index.js +10 -7
  27. package/dist/modules/Payment/utils.js +3 -0
  28. package/dist/modules/Payment/walletpass.d.ts +23 -0
  29. package/dist/modules/Payment/walletpass.js +191 -95
  30. package/dist/modules/Product/utils.js +2 -2
  31. package/dist/modules/ProductList/index.d.ts +2 -4
  32. package/dist/modules/ProductList/index.js +12 -24
  33. package/dist/modules/Rules/index.d.ts +9 -5
  34. package/dist/modules/Rules/index.js +669 -173
  35. package/dist/modules/Rules/types.d.ts +2 -0
  36. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  37. package/dist/modules/Schedule/utils.d.ts +1 -1
  38. package/dist/modules/Summary/types.d.ts +2 -0
  39. package/dist/modules/Summary/utils.d.ts +9 -3
  40. package/dist/modules/Summary/utils.js +57 -67
  41. package/dist/modules/index.d.ts +0 -4
  42. package/dist/modules/index.js +1 -5
  43. package/dist/plugins/window.d.ts +2 -0
  44. package/dist/solution/BookingByStep/index.d.ts +3 -2
  45. package/dist/solution/BookingByStep/index.js +43 -46
  46. package/dist/solution/BookingByStep/types.d.ts +1 -3
  47. package/dist/solution/BookingByStep/types.js +1 -5
  48. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  49. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  50. package/dist/solution/Checkout/index.js +2 -0
  51. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  52. package/dist/solution/ShopDiscount/index.js +60 -62
  53. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  54. package/dist/solution/ShopDiscount/types.js +2 -1
  55. package/dist/solution/ShopDiscount/utils.js +26 -12
  56. package/dist/solution/index.d.ts +0 -2
  57. package/dist/solution/index.js +1 -3
  58. package/lib/index.d.ts +1 -1
  59. package/lib/index.js +3 -4
  60. package/lib/model/strategy/adapter/index.d.ts +0 -4
  61. package/lib/model/strategy/adapter/index.js +2 -13
  62. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  63. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  64. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  65. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  66. package/lib/model/strategy/engine.d.ts +18 -5
  67. package/lib/model/strategy/engine.js +85 -21
  68. package/lib/model/strategy/type.d.ts +17 -0
  69. package/lib/modules/Cart/types.d.ts +2 -0
  70. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  71. package/lib/modules/Cart/utils/changePrice.js +9 -13
  72. package/lib/modules/Discount/index.d.ts +4 -13
  73. package/lib/modules/Discount/index.js +5 -76
  74. package/lib/modules/Discount/types.d.ts +18 -13
  75. package/lib/modules/Order/index.d.ts +1 -67
  76. package/lib/modules/Order/index.js +1 -525
  77. package/lib/modules/Order/types.d.ts +12 -176
  78. package/lib/modules/Order/utils.d.ts +0 -118
  79. package/lib/modules/Order/utils.js +2 -483
  80. package/lib/modules/Payment/index.d.ts +2 -1
  81. package/lib/modules/Payment/index.js +1 -0
  82. package/lib/modules/Payment/utils.js +3 -0
  83. package/lib/modules/Payment/walletpass.d.ts +23 -0
  84. package/lib/modules/Payment/walletpass.js +94 -17
  85. package/lib/modules/Product/utils.js +2 -2
  86. package/lib/modules/ProductList/index.d.ts +2 -4
  87. package/lib/modules/ProductList/index.js +39 -46
  88. package/lib/modules/Rules/index.d.ts +9 -5
  89. package/lib/modules/Rules/index.js +776 -292
  90. package/lib/modules/Rules/types.d.ts +2 -0
  91. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  92. package/lib/modules/Schedule/utils.d.ts +1 -1
  93. package/lib/modules/Summary/types.d.ts +2 -0
  94. package/lib/modules/Summary/utils.d.ts +9 -3
  95. package/lib/modules/Summary/utils.js +34 -45
  96. package/lib/modules/index.d.ts +0 -4
  97. package/lib/modules/index.js +1 -9
  98. package/lib/plugins/window.d.ts +2 -0
  99. package/lib/solution/BookingByStep/index.d.ts +3 -2
  100. package/lib/solution/BookingByStep/index.js +4 -6
  101. package/lib/solution/BookingByStep/types.d.ts +1 -3
  102. package/lib/solution/BookingByStep/types.js +0 -10
  103. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  104. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  105. package/lib/solution/Checkout/index.js +2 -0
  106. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  107. package/lib/solution/ShopDiscount/index.js +27 -22
  108. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  109. package/lib/solution/ShopDiscount/utils.js +10 -6
  110. package/lib/solution/index.d.ts +0 -2
  111. package/lib/solution/index.js +1 -5
  112. package/package.json +2 -2
  113. package/dist/apis/picoding.d.ts +0 -0
  114. package/dist/apis/picoding.js +0 -1
  115. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  116. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  117. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -780
  119. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  120. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  121. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  122. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  124. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  125. package/dist/modules/OpenData/index.d.ts +0 -24
  126. package/dist/modules/OpenData/index.js +0 -173
  127. package/dist/modules/OpenData/types.d.ts +0 -73
  128. package/dist/modules/OpenData/types.js +0 -1
  129. package/dist/modules/OpenData/utils.d.ts +0 -2
  130. package/dist/modules/OpenData/utils.js +0 -75
  131. package/dist/modules/Quotation/index.d.ts +0 -48
  132. package/dist/modules/Quotation/index.js +0 -248
  133. package/dist/modules/Quotation/types.d.ts +0 -42
  134. package/dist/modules/Quotation/types.js +0 -1
  135. package/dist/modules/SalesSummary/index.d.ts +0 -63
  136. package/dist/modules/SalesSummary/index.js +0 -174
  137. package/dist/modules/SalesSummary/types.d.ts +0 -60
  138. package/dist/modules/SalesSummary/types.js +0 -1
  139. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  140. package/dist/modules/SalesSummary/utils.js +0 -480
  141. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  142. package/dist/modules/ScanOrderLogger/index.js +0 -174
  143. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  144. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  145. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  146. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  147. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  148. package/dist/modules/ScanOrderLogger/types.js +0 -1
  149. package/dist/solution/ScanOrder/index.d.ts +0 -158
  150. package/dist/solution/ScanOrder/index.js +0 -3474
  151. package/dist/solution/ScanOrder/types.d.ts +0 -306
  152. package/dist/solution/ScanOrder/types.js +0 -35
  153. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  154. package/dist/solution/ScanOrder/utils.js +0 -796
  155. package/dist/solution/VenueBooking/index.d.ts +0 -262
  156. package/dist/solution/VenueBooking/index.js +0 -3991
  157. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  158. package/dist/solution/VenueBooking/types.d.ts +0 -156
  159. package/dist/solution/VenueBooking/types.js +0 -22
  160. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  161. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  162. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  163. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  164. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  165. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  166. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  167. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  168. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  169. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  170. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  171. package/dist/solution/VenueBooking/utils.js +0 -1
  172. package/lib/apis/picoding.d.ts +0 -0
  173. package/lib/apis/picoding.js +0 -0
  174. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  175. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  176. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -583
  178. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  179. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  180. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  181. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  182. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -148
  183. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  184. package/lib/modules/OpenData/index.d.ts +0 -24
  185. package/lib/modules/OpenData/index.js +0 -119
  186. package/lib/modules/OpenData/types.d.ts +0 -73
  187. package/lib/modules/OpenData/types.js +0 -17
  188. package/lib/modules/OpenData/utils.d.ts +0 -2
  189. package/lib/modules/OpenData/utils.js +0 -111
  190. package/lib/modules/Quotation/index.d.ts +0 -48
  191. package/lib/modules/Quotation/index.js +0 -152
  192. package/lib/modules/Quotation/types.d.ts +0 -42
  193. package/lib/modules/Quotation/types.js +0 -17
  194. package/lib/modules/SalesSummary/index.d.ts +0 -63
  195. package/lib/modules/SalesSummary/index.js +0 -105
  196. package/lib/modules/SalesSummary/types.d.ts +0 -60
  197. package/lib/modules/SalesSummary/types.js +0 -17
  198. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  199. package/lib/modules/SalesSummary/utils.js +0 -420
  200. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  201. package/lib/modules/ScanOrderLogger/index.js +0 -147
  202. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  204. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  205. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  206. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  207. package/lib/modules/ScanOrderLogger/types.js +0 -17
  208. package/lib/solution/ScanOrder/index.d.ts +0 -158
  209. package/lib/solution/ScanOrder/index.js +0 -2135
  210. package/lib/solution/ScanOrder/types.d.ts +0 -306
  211. package/lib/solution/ScanOrder/types.js +0 -36
  212. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  213. package/lib/solution/ScanOrder/utils.js +0 -658
  214. package/lib/solution/VenueBooking/index.d.ts +0 -262
  215. package/lib/solution/VenueBooking/index.js +0 -2394
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  217. package/lib/solution/VenueBooking/types.d.ts +0 -156
  218. package/lib/solution/VenueBooking/types.js +0 -45
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  222. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  225. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  226. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -180
  227. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  228. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  229. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  230. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -1,73 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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);
@@ -1,2 +0,0 @@
1
- import type { OpenDataAvailabilityResult, ComputeAvailabilityParams } from './types';
2
- export declare function computeAvailability(params: ComputeAvailabilityParams): OpenDataAvailabilityResult;
@@ -1,111 +0,0 @@
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
- });
@@ -1,48 +0,0 @@
1
- import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { BaseModule } from '../BaseModule';
3
- import type { ScheduleItem } from '../Schedule/types';
4
- import type { QuotationItem } from './types';
5
- export type { QuotationItem, QuotationProductData, QuotationSchedule, QuotationState } from './types';
6
- export declare class QuotationModule extends BaseModule implements Module {
7
- protected defaultName: string;
8
- protected defaultVersion: string;
9
- private request;
10
- private store;
11
- private scheduleResolver?;
12
- constructor(name?: string, version?: string);
13
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
- loadQuotations(params?: {
15
- channel?: string;
16
- }): Promise<void>;
17
- getQuotationList(): QuotationItem[];
18
- /**
19
- * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
20
- * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
21
- *
22
- * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
23
- * First matching quotation whose schedule covers `datetime` and whose product_data contains
24
- * the requested productId wins.
25
- */
26
- getPriceForProduct(params: {
27
- productId: number;
28
- variantId?: number;
29
- datetime: string;
30
- }): string | null;
31
- getQuotationShelfId(params: {
32
- productId: number;
33
- variantId?: number;
34
- datetime: string;
35
- }): number;
36
- /**
37
- * Batch pre-compute quotation prices for a set of products across multiple time points.
38
- * Key format: `${productId}:${timePoint}`
39
- * This avoids repeated schedule matching when the same product appears in multiple resource rows.
40
- */
41
- buildProductPriceMap(params: {
42
- productIds: number[];
43
- timePoints: string[];
44
- }): Map<string, string | null>;
45
- setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
46
- private isQuotationActiveAt;
47
- private findProductData;
48
- }
@@ -1,152 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/modules/Quotation/index.ts
20
- var Quotation_exports = {};
21
- __export(Quotation_exports, {
22
- QuotationModule: () => QuotationModule
23
- });
24
- module.exports = __toCommonJS(Quotation_exports);
25
- var import_BaseModule = require("../BaseModule");
26
- var import_getDateIsInSchedule = require("../Schedule/getDateIsInSchedule");
27
- var QuotationModule = class extends import_BaseModule.BaseModule {
28
- constructor(name, version) {
29
- super(name, version);
30
- this.defaultName = "quotation";
31
- this.defaultVersion = "1.0.0";
32
- this.store = { list: [] };
33
- }
34
- async initialize(core, options) {
35
- this.core = core;
36
- this.request = core.getPlugin("request");
37
- if (!this.request)
38
- throw new Error("QuotationModule 需要 request 插件支持");
39
- this.store = { list: [] };
40
- }
41
- async loadQuotations(params) {
42
- var _a;
43
- const query = {};
44
- if (params == null ? void 0 : params.channel)
45
- query.channel = params.channel;
46
- if ((params == null ? void 0 : params.channel) === "online_store") {
47
- query.channel = "online-store";
48
- }
49
- const res = await this.request.get(
50
- "/quotation/available",
51
- query,
52
- { useCache: false }
53
- );
54
- const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
55
- list.sort((a, b) => b.sort - a.sort);
56
- this.store.list = list;
57
- }
58
- getQuotationList() {
59
- return this.store.list;
60
- }
61
- /**
62
- * Look up the quotation price for a specific product (+ optional variant) at a given datetime.
63
- * Returns the price as a string (e.g. "300.00"), or null if no quotation applies.
64
- *
65
- * Priority: iterates quotations already sorted by `sort` descending (highest = highest priority).
66
- * First matching quotation whose schedule covers `datetime` and whose product_data contains
67
- * the requested productId wins.
68
- */
69
- getPriceForProduct(params) {
70
- const { productId, variantId, datetime } = params;
71
- for (const quotation of this.store.list) {
72
- if (!this.isQuotationActiveAt(quotation, datetime))
73
- continue;
74
- const match = this.findProductData(quotation.product_data, productId, variantId);
75
- if (!match)
76
- continue;
77
- if (match.value === 0)
78
- continue;
79
- return String(match.value);
80
- }
81
- return null;
82
- }
83
- getQuotationShelfId(params) {
84
- const { productId, variantId, datetime } = params;
85
- for (const quotation of this.store.list) {
86
- if (!this.isQuotationActiveAt(quotation, datetime))
87
- continue;
88
- const match = this.findProductData(quotation.product_data, productId, variantId);
89
- if (!match || match.value === 0)
90
- continue;
91
- return quotation.id;
92
- }
93
- return 0;
94
- }
95
- /**
96
- * Batch pre-compute quotation prices for a set of products across multiple time points.
97
- * Key format: `${productId}:${timePoint}`
98
- * This avoids repeated schedule matching when the same product appears in multiple resource rows.
99
- */
100
- buildProductPriceMap(params) {
101
- const map = /* @__PURE__ */ new Map();
102
- if (!this.store.list.length)
103
- return map;
104
- for (const productId of params.productIds) {
105
- for (const timePoint of params.timePoints) {
106
- const key = `${productId}:${timePoint}`;
107
- const price = this.getPriceForProduct({ productId, datetime: timePoint });
108
- if (price !== null) {
109
- map.set(key, price);
110
- }
111
- }
112
- }
113
- return map;
114
- }
115
- setScheduleResolver(resolver) {
116
- this.scheduleResolver = resolver;
117
- }
118
- isQuotationActiveAt(quotation, datetime) {
119
- var _a;
120
- if (!((_a = quotation.schedule) == null ? void 0 : _a.length))
121
- return false;
122
- const scheduleItems = quotation.schedule.map((s) => {
123
- var _a2;
124
- const full = (_a2 = this.scheduleResolver) == null ? void 0 : _a2.call(this, s.id);
125
- if (full)
126
- return full;
127
- return {
128
- ...s,
129
- repeat_type: s.repeat_type || "none",
130
- repeat_rule: s.repeat_rule || null,
131
- time_slot: s.time_slot || []
132
- };
133
- });
134
- return (0, import_getDateIsInSchedule.getDateIsInSchedule)(datetime, scheduleItems);
135
- }
136
- findProductData(productData, productId, variantId) {
137
- if (variantId && variantId !== 0) {
138
- const variantMatch = productData.find(
139
- (p) => p.product_id === productId && p.variant_id === variantId
140
- );
141
- if (variantMatch)
142
- return variantMatch;
143
- }
144
- return productData.find(
145
- (p) => p.product_id === productId && p.variant_id === 0
146
- );
147
- }
148
- };
149
- // Annotate the CommonJS export names for ESM import in node:
150
- 0 && (module.exports = {
151
- QuotationModule
152
- });
@@ -1,42 +0,0 @@
1
- export interface QuotationProductData {
2
- id: number;
3
- shelf_id: number;
4
- product_id: number;
5
- variant_id: number;
6
- type: string;
7
- value: number;
8
- }
9
- export interface QuotationSchedule {
10
- id: number;
11
- name: string;
12
- type: 'standard' | 'time-slots' | 'designation';
13
- start_time: string;
14
- end_time: string;
15
- is_all: number;
16
- repeat_type?: string;
17
- repeat_rule?: any;
18
- designation?: any;
19
- time_slot?: Array<{
20
- start_time: string;
21
- end_time: string;
22
- }>;
23
- pivot?: Record<string, any>;
24
- }
25
- export interface QuotationItem {
26
- id: number;
27
- shop_id: number;
28
- shelf_type_id?: number;
29
- name: string;
30
- description?: string;
31
- status: string;
32
- sort: number;
33
- channel: string[];
34
- created_at?: string;
35
- updated_at?: string;
36
- deleted_at?: string | null;
37
- schedule: QuotationSchedule[];
38
- product_data: QuotationProductData[];
39
- }
40
- export interface QuotationState {
41
- list: QuotationItem[];
42
- }
@@ -1,17 +0,0 @@
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/Quotation/types.ts
16
- var types_exports = {};
17
- module.exports = __toCommonJS(types_exports);
@@ -1,63 +0,0 @@
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
- }): Promise<{
19
- tax_title: any;
20
- tax_rate: any;
21
- product_quantity: number;
22
- product_original_amount: string;
23
- product_amount: string;
24
- product_expect_amount: string;
25
- product_tax_fee: string;
26
- shipping_fee: string;
27
- shipping_tax_fee: string;
28
- tax_fee: string;
29
- surcharge_fee: string;
30
- surcharges: any[];
31
- discount_amount: string;
32
- deposit_amount: string;
33
- deposit?: import("./types").DepositInfo | undefined;
34
- expect_amount: string;
35
- total_amount: string;
36
- amount_gap: string;
37
- rounding_amount: string;
38
- pay_service_charge_amount: string;
39
- is_price_include_tax?: number | undefined;
40
- } | {
41
- tax_title: any;
42
- tax_rate: any;
43
- product_quantity: number;
44
- product_original_amount: string;
45
- product_amount: string;
46
- product_expect_amount: string;
47
- product_tax_fee: string;
48
- shipping_fee: string;
49
- shipping_tax_fee: string;
50
- tax_fee: string;
51
- surcharge_fee: string;
52
- surcharges: any;
53
- discount_amount: string;
54
- deposit_amount: string;
55
- deposit: import("./types").DepositInfo | undefined;
56
- expect_amount: string;
57
- total_amount: string;
58
- amount_gap: string;
59
- rounding_amount: string;
60
- pay_service_charge_amount: string;
61
- is_price_include_tax: number;
62
- }>;
63
- }
@@ -1,105 +0,0 @@
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 } = 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
- });
92
- const summaryWithTaxMeta = {
93
- ...summary,
94
- tax_title: (shopInfo == null ? void 0 : shopInfo.tax_title) || "",
95
- tax_rate: taxRate ?? (shopInfo == null ? void 0 : shopInfo.tax_rate)
96
- };
97
- this.store.summary = summaryWithTaxMeta;
98
- return summaryWithTaxMeta;
99
- }
100
- };
101
- // Annotate the CommonJS export names for ESM import in node:
102
- 0 && (module.exports = {
103
- SalesSummaryModule,
104
- ...require("./types")
105
- });