@pisell/pisellos 2.1.170 → 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 (231) 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/promotion/index.js +0 -9
  7. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  8. package/dist/model/strategy/adapter/walletPass/evaluator.js +61 -8
  9. package/dist/model/strategy/adapter/walletPass/locales.js +12 -3
  10. package/dist/model/strategy/engine.d.ts +18 -5
  11. package/dist/model/strategy/engine.js +145 -45
  12. package/dist/model/strategy/type.d.ts +17 -0
  13. package/dist/model/strategy/type.js +4 -0
  14. package/dist/modules/Cart/types.d.ts +2 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +56 -25
  16. package/dist/modules/Cart/utils/changePrice.js +9 -16
  17. package/dist/modules/Discount/index.d.ts +4 -13
  18. package/dist/modules/Discount/index.js +12 -124
  19. package/dist/modules/Discount/types.d.ts +18 -13
  20. package/dist/modules/Order/index.d.ts +1 -67
  21. package/dist/modules/Order/index.js +30 -918
  22. package/dist/modules/Order/types.d.ts +12 -176
  23. package/dist/modules/Order/types.js +0 -2
  24. package/dist/modules/Order/utils.d.ts +0 -118
  25. package/dist/modules/Order/utils.js +2 -586
  26. package/dist/modules/Payment/index.d.ts +2 -1
  27. package/dist/modules/Payment/index.js +10 -7
  28. package/dist/modules/Payment/utils.js +3 -0
  29. package/dist/modules/Payment/walletpass.d.ts +23 -0
  30. package/dist/modules/Payment/walletpass.js +191 -95
  31. package/dist/modules/Product/utils.js +2 -2
  32. package/dist/modules/ProductList/index.d.ts +2 -4
  33. package/dist/modules/ProductList/index.js +12 -24
  34. package/dist/modules/Rules/index.d.ts +9 -5
  35. package/dist/modules/Rules/index.js +669 -173
  36. package/dist/modules/Rules/types.d.ts +2 -0
  37. package/dist/modules/Schedule/getDateIsInSchedule.js +18 -16
  38. package/dist/modules/Schedule/utils.d.ts +1 -1
  39. package/dist/modules/Summary/types.d.ts +2 -0
  40. package/dist/modules/Summary/utils.d.ts +9 -3
  41. package/dist/modules/Summary/utils.js +57 -67
  42. package/dist/modules/index.d.ts +0 -4
  43. package/dist/modules/index.js +1 -5
  44. package/dist/plugins/window.d.ts +2 -0
  45. package/dist/solution/BookingByStep/index.d.ts +3 -2
  46. package/dist/solution/BookingByStep/index.js +43 -46
  47. package/dist/solution/BookingByStep/types.d.ts +1 -3
  48. package/dist/solution/BookingByStep/types.js +1 -5
  49. package/dist/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  50. package/dist/solution/BookingByStep/utils/timeslots.js +12 -19
  51. package/dist/solution/Checkout/index.js +2 -0
  52. package/dist/solution/ShopDiscount/index.d.ts +2 -3
  53. package/dist/solution/ShopDiscount/index.js +60 -62
  54. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  55. package/dist/solution/ShopDiscount/types.js +2 -1
  56. package/dist/solution/ShopDiscount/utils.js +26 -12
  57. package/dist/solution/index.d.ts +0 -2
  58. package/dist/solution/index.js +1 -3
  59. package/lib/index.d.ts +1 -1
  60. package/lib/index.js +3 -4
  61. package/lib/model/strategy/adapter/index.d.ts +0 -4
  62. package/lib/model/strategy/adapter/index.js +2 -13
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +57 -8
  64. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  65. package/lib/model/strategy/adapter/walletPass/evaluator.js +34 -3
  66. package/lib/model/strategy/adapter/walletPass/locales.js +12 -3
  67. package/lib/model/strategy/engine.d.ts +18 -5
  68. package/lib/model/strategy/engine.js +85 -21
  69. package/lib/model/strategy/type.d.ts +17 -0
  70. package/lib/modules/Cart/types.d.ts +2 -0
  71. package/lib/modules/Cart/utils/cartProduct.js +39 -12
  72. package/lib/modules/Cart/utils/changePrice.js +9 -13
  73. package/lib/modules/Discount/index.d.ts +4 -13
  74. package/lib/modules/Discount/index.js +5 -76
  75. package/lib/modules/Discount/types.d.ts +18 -13
  76. package/lib/modules/Order/index.d.ts +1 -67
  77. package/lib/modules/Order/index.js +1 -525
  78. package/lib/modules/Order/types.d.ts +12 -176
  79. package/lib/modules/Order/utils.d.ts +0 -118
  80. package/lib/modules/Order/utils.js +2 -483
  81. package/lib/modules/Payment/index.d.ts +2 -1
  82. package/lib/modules/Payment/index.js +1 -0
  83. package/lib/modules/Payment/utils.js +3 -0
  84. package/lib/modules/Payment/walletpass.d.ts +23 -0
  85. package/lib/modules/Payment/walletpass.js +94 -17
  86. package/lib/modules/Product/utils.js +2 -2
  87. package/lib/modules/ProductList/index.d.ts +2 -4
  88. package/lib/modules/ProductList/index.js +39 -46
  89. package/lib/modules/Rules/index.d.ts +9 -5
  90. package/lib/modules/Rules/index.js +776 -292
  91. package/lib/modules/Rules/types.d.ts +2 -0
  92. package/lib/modules/Schedule/getDateIsInSchedule.js +11 -13
  93. package/lib/modules/Schedule/utils.d.ts +1 -1
  94. package/lib/modules/Summary/types.d.ts +2 -0
  95. package/lib/modules/Summary/utils.d.ts +9 -3
  96. package/lib/modules/Summary/utils.js +34 -45
  97. package/lib/modules/index.d.ts +0 -4
  98. package/lib/modules/index.js +1 -9
  99. package/lib/plugins/window.d.ts +2 -0
  100. package/lib/solution/BookingByStep/index.d.ts +3 -2
  101. package/lib/solution/BookingByStep/index.js +4 -6
  102. package/lib/solution/BookingByStep/types.d.ts +1 -3
  103. package/lib/solution/BookingByStep/types.js +0 -10
  104. package/lib/solution/BookingByStep/utils/timeslots.d.ts +1 -3
  105. package/lib/solution/BookingByStep/utils/timeslots.js +11 -19
  106. package/lib/solution/Checkout/index.js +2 -0
  107. package/lib/solution/ShopDiscount/index.d.ts +2 -3
  108. package/lib/solution/ShopDiscount/index.js +27 -22
  109. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  110. package/lib/solution/ShopDiscount/utils.js +10 -6
  111. package/lib/solution/index.d.ts +0 -2
  112. package/lib/solution/index.js +1 -5
  113. package/package.json +2 -2
  114. package/dist/apis/picoding.d.ts +0 -0
  115. package/dist/apis/picoding.js +0 -1
  116. package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  117. package/dist/model/strategy/adapter/dataVariant/adapter.js +0 -167
  118. package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  119. package/dist/model/strategy/adapter/dataVariant/evaluator.js +0 -867
  120. package/dist/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  121. package/dist/model/strategy/adapter/dataVariant/examples.js +0 -277
  122. package/dist/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  123. package/dist/model/strategy/adapter/dataVariant/index.js +0 -4
  124. package/dist/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  125. package/dist/model/strategy/adapter/dataVariant/type.js +0 -54
  126. package/dist/modules/OpenData/index.d.ts +0 -24
  127. package/dist/modules/OpenData/index.js +0 -173
  128. package/dist/modules/OpenData/types.d.ts +0 -73
  129. package/dist/modules/OpenData/types.js +0 -1
  130. package/dist/modules/OpenData/utils.d.ts +0 -2
  131. package/dist/modules/OpenData/utils.js +0 -75
  132. package/dist/modules/Quotation/index.d.ts +0 -48
  133. package/dist/modules/Quotation/index.js +0 -248
  134. package/dist/modules/Quotation/types.d.ts +0 -42
  135. package/dist/modules/Quotation/types.js +0 -1
  136. package/dist/modules/SalesSummary/index.d.ts +0 -63
  137. package/dist/modules/SalesSummary/index.js +0 -174
  138. package/dist/modules/SalesSummary/types.d.ts +0 -60
  139. package/dist/modules/SalesSummary/types.js +0 -1
  140. package/dist/modules/SalesSummary/utils.d.ts +0 -30
  141. package/dist/modules/SalesSummary/utils.js +0 -480
  142. package/dist/modules/ScanOrderLogger/index.d.ts +0 -23
  143. package/dist/modules/ScanOrderLogger/index.js +0 -174
  144. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  145. package/dist/modules/ScanOrderLogger/providers/feishu.js +0 -221
  146. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  147. package/dist/modules/ScanOrderLogger/providers/grafana.js +0 -50
  148. package/dist/modules/ScanOrderLogger/types.d.ts +0 -53
  149. package/dist/modules/ScanOrderLogger/types.js +0 -1
  150. package/dist/solution/ScanOrder/index.d.ts +0 -158
  151. package/dist/solution/ScanOrder/index.js +0 -3474
  152. package/dist/solution/ScanOrder/types.d.ts +0 -306
  153. package/dist/solution/ScanOrder/types.js +0 -35
  154. package/dist/solution/ScanOrder/utils.d.ts +0 -172
  155. package/dist/solution/ScanOrder/utils.js +0 -796
  156. package/dist/solution/VenueBooking/index.d.ts +0 -252
  157. package/dist/solution/VenueBooking/index.js +0 -3769
  158. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  159. package/dist/solution/VenueBooking/types.d.ts +0 -156
  160. package/dist/solution/VenueBooking/types.js +0 -22
  161. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  162. package/dist/solution/VenueBooking/utils/dateSummary.js +0 -91
  163. package/dist/solution/VenueBooking/utils/resource.d.ts +0 -14
  164. package/dist/solution/VenueBooking/utils/resource.js +0 -131
  165. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  166. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -233
  167. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  168. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -302
  169. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  170. package/dist/solution/VenueBooking/utils/timeSlot.js +0 -458
  171. package/dist/solution/VenueBooking/utils.d.ts +0 -1
  172. package/dist/solution/VenueBooking/utils.js +0 -1
  173. package/lib/apis/picoding.d.ts +0 -0
  174. package/lib/apis/picoding.js +0 -0
  175. package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +0 -50
  176. package/lib/model/strategy/adapter/dataVariant/adapter.js +0 -149
  177. package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +0 -89
  178. package/lib/model/strategy/adapter/dataVariant/evaluator.js +0 -666
  179. package/lib/model/strategy/adapter/dataVariant/examples.d.ts +0 -39
  180. package/lib/model/strategy/adapter/dataVariant/examples.js +0 -293
  181. package/lib/model/strategy/adapter/dataVariant/index.d.ts +0 -4
  182. package/lib/model/strategy/adapter/dataVariant/index.js +0 -38
  183. package/lib/model/strategy/adapter/dataVariant/type.d.ts +0 -149
  184. package/lib/model/strategy/adapter/dataVariant/type.js +0 -31
  185. package/lib/modules/OpenData/index.d.ts +0 -24
  186. package/lib/modules/OpenData/index.js +0 -119
  187. package/lib/modules/OpenData/types.d.ts +0 -73
  188. package/lib/modules/OpenData/types.js +0 -17
  189. package/lib/modules/OpenData/utils.d.ts +0 -2
  190. package/lib/modules/OpenData/utils.js +0 -111
  191. package/lib/modules/Quotation/index.d.ts +0 -48
  192. package/lib/modules/Quotation/index.js +0 -152
  193. package/lib/modules/Quotation/types.d.ts +0 -42
  194. package/lib/modules/Quotation/types.js +0 -17
  195. package/lib/modules/SalesSummary/index.d.ts +0 -63
  196. package/lib/modules/SalesSummary/index.js +0 -105
  197. package/lib/modules/SalesSummary/types.d.ts +0 -60
  198. package/lib/modules/SalesSummary/types.js +0 -17
  199. package/lib/modules/SalesSummary/utils.d.ts +0 -30
  200. package/lib/modules/SalesSummary/utils.js +0 -420
  201. package/lib/modules/ScanOrderLogger/index.d.ts +0 -23
  202. package/lib/modules/ScanOrderLogger/index.js +0 -147
  203. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +0 -2
  204. package/lib/modules/ScanOrderLogger/providers/feishu.js +0 -157
  205. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +0 -2
  206. package/lib/modules/ScanOrderLogger/providers/grafana.js +0 -52
  207. package/lib/modules/ScanOrderLogger/types.d.ts +0 -53
  208. package/lib/modules/ScanOrderLogger/types.js +0 -17
  209. package/lib/solution/ScanOrder/index.d.ts +0 -158
  210. package/lib/solution/ScanOrder/index.js +0 -2135
  211. package/lib/solution/ScanOrder/types.d.ts +0 -306
  212. package/lib/solution/ScanOrder/types.js +0 -36
  213. package/lib/solution/ScanOrder/utils.d.ts +0 -172
  214. package/lib/solution/ScanOrder/utils.js +0 -658
  215. package/lib/solution/VenueBooking/index.d.ts +0 -252
  216. package/lib/solution/VenueBooking/index.js +0 -2204
  217. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -343
  218. package/lib/solution/VenueBooking/types.d.ts +0 -156
  219. package/lib/solution/VenueBooking/types.js +0 -45
  220. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +0 -11
  221. package/lib/solution/VenueBooking/utils/dateSummary.js +0 -105
  222. package/lib/solution/VenueBooking/utils/resource.d.ts +0 -14
  223. package/lib/solution/VenueBooking/utils/resource.js +0 -92
  224. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -32
  225. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -236
  226. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -71
  227. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -225
  228. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -34
  229. package/lib/solution/VenueBooking/utils/timeSlot.js +0 -343
  230. package/lib/solution/VenueBooking/utils.d.ts +0 -1
  231. package/lib/solution/VenueBooking/utils.js +0 -69
@@ -29,152 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/modules/Order/utils.ts
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
- buildSubmitPayload: () => buildSubmitPayload,
33
- composeLinePrice: () => composeLinePrice,
34
- createDefaultOrderRulesHooks: () => createDefaultOrderRulesHooks,
35
- createDefaultTempOrder: () => createDefaultTempOrder,
36
- createEmptySummary: () => import_utils2.createEmptySummary,
37
- createUuidV4: () => createUuidV4,
38
- filterProductsForScanOrderMore: () => filterProductsForScanOrderMore,
39
- formatDateTime: () => formatDateTime,
40
- formatV1Product: () => formatV1Product,
41
32
  generateDuration: () => generateDuration,
42
33
  getAllDiscountList: () => getAllDiscountList,
43
- isTempOrder: () => isTempOrder,
44
- mergeRelationForms: () => mergeRelationForms,
45
- normalizeSubmitBooking: () => normalizeSubmitBooking,
46
- normalizeSubmitCollectPaxValue: () => normalizeSubmitCollectPaxValue,
47
- resolveSubmitCollectPax: () => resolveSubmitCollectPax,
48
- sumOptionUnitPrice: () => sumOptionUnitPrice
34
+ mergeRelationForms: () => mergeRelationForms
49
35
  });
50
36
  module.exports = __toCommonJS(utils_exports);
51
37
  var import_dayjs = __toESM(require("dayjs"));
52
- var import_decimal = __toESM(require("decimal.js"));
53
- var import_utils = require("../../solution/ScanOrder/utils");
54
- var import_utils2 = require("../../solution/ScanOrder/utils");
55
- function composeLinePrice(params) {
56
- const { mainPrice, bundle, useOriginalBundle } = params;
57
- let total = new import_decimal.default(Number(mainPrice) || 0);
58
- if (Array.isArray(bundle)) {
59
- for (const item of bundle) {
60
- const rawPrice = useOriginalBundle ? (item == null ? void 0 : item.original_price) ?? (item == null ? void 0 : item.product_price) ?? (item == null ? void 0 : item.price) : (item == null ? void 0 : item.bundle_selling_price) ?? (item == null ? void 0 : item.price);
61
- const price = new import_decimal.default(Number(rawPrice) || 0);
62
- const rawNum = (item == null ? void 0 : item.num) ?? (item == null ? void 0 : item.quantity) ?? 1;
63
- const num = new import_decimal.default(Number(rawNum) || 0);
64
- total = total.plus(price.times(num));
65
- }
66
- }
67
- return total.toDecimalPlaces(2).toFixed(2);
68
- }
69
- function sumOptionUnitPrice(options) {
70
- let total = new import_decimal.default(0);
71
- if (!Array.isArray(options))
72
- return total;
73
- for (const opt of options) {
74
- const price = new import_decimal.default(Number(opt == null ? void 0 : opt.price) || 0);
75
- const num = new import_decimal.default(Number(opt == null ? void 0 : opt.num) || 0);
76
- total = total.plus(price.times(num));
77
- }
78
- return total;
79
- }
80
- function createDefaultOrderRulesHooks() {
81
- const toUnitPriceString = (totalLike, num) => {
82
- const effectiveNum = Number(num) > 0 ? Number(num) : 1;
83
- return new import_decimal.default(Number(totalLike) || 0).dividedBy(effectiveNum).toDecimalPlaces(2).toString();
84
- };
85
- return {
86
- getProduct: (product) => {
87
- var _a, _b, _c, _d;
88
- const metadataAny = product.metadata || {};
89
- const optionSum = sumOptionUnitPrice(product.product_option_item);
90
- let sourcePrice;
91
- if (metadataAny.source_product_price !== void 0) {
92
- sourcePrice = String(metadataAny.source_product_price);
93
- } else if (metadataAny.main_product_selling_price !== void 0) {
94
- sourcePrice = new import_decimal.default(
95
- Number(metadataAny.main_product_selling_price) || 0
96
- ).minus(optionSum).toDecimalPlaces(2).toString();
97
- } else {
98
- sourcePrice = String(product.selling_price ?? 0);
99
- }
100
- let sourceOriginalPrice;
101
- if (metadataAny.source_product_price !== void 0) {
102
- sourceOriginalPrice = String(metadataAny.source_product_price);
103
- } else if (metadataAny.main_product_original_price !== void 0) {
104
- sourceOriginalPrice = new import_decimal.default(
105
- Number(metadataAny.main_product_original_price) || 0
106
- ).minus(optionSum).toDecimalPlaces(2).toString();
107
- } else {
108
- sourceOriginalPrice = sourcePrice;
109
- }
110
- return {
111
- id: product.product_id,
112
- // Rules 引擎用 _id 作为 processedProductsMap 键;必须与购物车行级 identity 一致,
113
- // 否则同 SKU 不同小料会在 calcDiscount 重组时互相覆盖。
114
- // 不透明 identity 契约下,normalizeOrderProduct / restoreTempOrderFromStorage 已保证 identity_key 必存在;
115
- // 留 fingerprint 分支仅作 Rules 单测里直接传裸 product 时的兜底。
116
- _id: product.identity_key ? `${product.product_id}_${product.product_variant_id}_${product.identity_key}` : `${product.product_id}_${product.product_variant_id}_${(0, import_utils.buildProductLineFingerprint)(
117
- product.product_option_item,
118
- product.product_bundle
119
- )}`,
120
- // Rules 内部 getProductTotalPrice / getProductOriginTotalPrice 会各自再叠加 bundle + option,
121
- // 所以这里必须喂 source-level(不含 option、不含 bundle、不含折扣)单价,避免双加 option。
122
- price: sourcePrice,
123
- // total / origin_total 使用 composite × num,跟 Rules 内部产出的 total 对齐(含 option + bundle)。
124
- total: new import_decimal.default(product.selling_price || 0).times(product.num || 1).toNumber(),
125
- origin_total: new import_decimal.default(
126
- product.original_price || product.selling_price || 0
127
- ).times(product.num || 1).toNumber(),
128
- original_price: sourceOriginalPrice,
129
- quantity: product.num || 1,
130
- num: product.num || 1,
131
- discount_list: product.discount_list || [],
132
- bundle: product.product_bundle || [],
133
- booking_id: ((_a = product._origin) == null ? void 0 : _a.booking_id) || null,
134
- isClient: false,
135
- isManualDiscount: ((_b = product._origin) == null ? void 0 : _b.isManualDiscount) || false,
136
- holder_id: (_c = product._origin) == null ? void 0 : _c.holder_id,
137
- startDate: (_d = product._origin) == null ? void 0 : _d.startDate
138
- };
139
- },
140
- setProduct: (product, values) => {
141
- const nextNum = Number(values.quantity ?? product.num ?? 1) || 1;
142
- const metadataAny = product.metadata || {};
143
- const existedSource = metadataAny.source_product_price ?? product.selling_price ?? "0";
144
- const nextOptions = product.product_option_item;
145
- const optionSum = sumOptionUnitPrice(nextOptions);
146
- const nextSourceSellingPrice = values.main_product_selling_price !== void 0 ? String(values.main_product_selling_price) : values.price !== void 0 ? String(values.price) : values.total !== void 0 ? toUnitPriceString(values.total, nextNum) : String(existedSource);
147
- const nextSourceOriginalPrice = values.original_price !== void 0 ? String(values.original_price) : String(existedSource);
148
- const nextMainSellingPrice = new import_decimal.default(Number(nextSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
149
- const nextMainOriginalPrice = new import_decimal.default(Number(nextSourceOriginalPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
150
- const nextBundle = values.bundle ?? product.product_bundle;
151
- const composedSellingPrice = composeLinePrice({
152
- mainPrice: nextMainSellingPrice,
153
- bundle: nextBundle
154
- });
155
- const composedOriginalPrice = composeLinePrice({
156
- mainPrice: nextMainOriginalPrice,
157
- bundle: nextBundle,
158
- useOriginalBundle: true
159
- });
160
- return {
161
- ...product,
162
- selling_price: composedSellingPrice,
163
- original_price: composedOriginalPrice,
164
- discount_list: values.discount_list ?? product.discount_list,
165
- num: values.quantity ?? product.num,
166
- product_bundle: nextBundle,
167
- metadata: {
168
- ...metadataAny,
169
- source_product_price: nextSourceOriginalPrice,
170
- main_product_selling_price: nextMainSellingPrice,
171
- main_product_original_price: nextMainOriginalPrice,
172
- price_schema_version: 2
173
- }
174
- };
175
- }
176
- };
177
- }
178
38
  var generateDuration = (cartItem) => {
179
39
  const startDate = (0, import_dayjs.default)(`${cartItem.start_date} ${cartItem.start_time}`);
180
40
  const endDate = (0, import_dayjs.default)(`${cartItem.end_date} ${cartItem.end_time}`);
@@ -205,350 +65,9 @@ var getAllDiscountList = (cartItem) => {
205
65
  });
206
66
  return discountList;
207
67
  };
208
- function createUuidV4() {
209
- const template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
210
- return template.replace(/[xy]/g, (char) => {
211
- const randomValue = Math.floor(Math.random() * 16);
212
- const value = char === "x" ? randomValue : randomValue & 3 | 8;
213
- return value.toString(16);
214
- });
215
- }
216
- function isTempOrder(data) {
217
- if (!data || typeof data !== "object")
218
- return false;
219
- if (!Array.isArray(data.products))
220
- return false;
221
- return true;
222
- }
223
- function formatDateTime(date) {
224
- const pad = (value) => value.toString().padStart(2, "0");
225
- const year = date.getFullYear();
226
- const month = pad(date.getMonth() + 1);
227
- const day = pad(date.getDate());
228
- const hours = pad(date.getHours());
229
- const minutes = pad(date.getMinutes());
230
- const seconds = pad(date.getSeconds());
231
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
232
- }
233
- function normalizeSubmitPlatform(platform) {
234
- return (platform == null ? void 0 : platform.toLowerCase()) === "pc" ? "PC" : "H5";
235
- }
236
- function formatSubmitOptionItems(options) {
237
- if (!Array.isArray(options))
238
- return [];
239
- return options.map((d) => ({
240
- num: d == null ? void 0 : d.num,
241
- option_group_item_id: (d == null ? void 0 : d.option_group_item_id) ?? (d == null ? void 0 : d.product_option_item_id),
242
- option_group_id: d == null ? void 0 : d.option_group_id
243
- }));
244
- }
245
- function toBundleNumber(value, fallback = 0) {
246
- const parsed = Number(value);
247
- return Number.isFinite(parsed) ? parsed : fallback;
248
- }
249
- function formatSubmitBundleItems(bundle) {
250
- if (!Array.isArray(bundle))
251
- return [];
252
- return bundle.map((b) => {
253
- const rawBundle = b && typeof b === "object" ? b : {};
254
- const existedMetadata = rawBundle.metadata && typeof rawBundle.metadata === "object" ? rawBundle.metadata : {};
255
- const sellingPriceNum = toBundleNumber(
256
- rawBundle.bundle_selling_price ?? rawBundle.price,
257
- 0
258
- );
259
- const priceNum = toBundleNumber(rawBundle.price, sellingPriceNum);
260
- const priceType = rawBundle.price_type ?? "";
261
- const relationSurchargeIds = Array.isArray(rawBundle.relation_surcharge_ids) ? rawBundle.relation_surcharge_ids : Array.isArray(existedMetadata.relation_surcharge_ids) ? existedMetadata.relation_surcharge_ids : [];
262
- const surchargeFee = toBundleNumber(
263
- rawBundle.surcharge_fee ?? existedMetadata.surcharge_fee,
264
- 0
265
- );
266
- const productDiscountDifference = toBundleNumber(
267
- existedMetadata.product_discount_difference,
268
- 0
269
- );
270
- return {
271
- ...rawBundle,
272
- is_charge_tax: rawBundle.is_charge_tax ?? 0,
273
- tax_fee: toBundleNumber(rawBundle.tax_fee, 0),
274
- bundle_variant_id: rawBundle.bundle_variant_id ?? 0,
275
- num: toBundleNumber(rawBundle.num, 1),
276
- extension_id: rawBundle.extension_id ?? 0,
277
- extension_type: rawBundle.extension_type ?? "normal",
278
- price: priceNum,
279
- price_type: priceType,
280
- price_type_ext: rawBundle.price_type_ext ?? "",
281
- // custom_price: customPriceStr,
282
- custom_price_type: rawBundle.custom_price_type ?? priceType ?? "",
283
- bundle_selling_price: sellingPriceNum,
284
- option: formatSubmitOptionItems(rawBundle.option),
285
- bundle_group_id: rawBundle == null ? void 0 : rawBundle.group_id,
286
- bundle_id: rawBundle == null ? void 0 : rawBundle.id,
287
- metadata: {
288
- ...existedMetadata,
289
- surcharge_fee: surchargeFee,
290
- relation_surcharge_ids: relationSurchargeIds,
291
- product_discount_difference: productDiscountDifference
292
- }
293
- };
294
- });
295
- }
296
- function normalizeSubmitProduct(product) {
297
- const { _origin, identity_key, ...submitProduct } = product;
298
- const rawMetadata = submitProduct.metadata || {};
299
- const bookingUid = rawMetadata.booking_uid;
300
- const cleanMetadata = {};
301
- if (rawMetadata.unique_identification_number) {
302
- cleanMetadata.unique_identification_number = rawMetadata.unique_identification_number;
303
- }
304
- const priceMetaKeys = [
305
- "main_product_original_price",
306
- "main_product_selling_price",
307
- "source_product_price",
308
- "price_schema_version"
309
- ];
310
- for (const key of priceMetaKeys) {
311
- if (rawMetadata[key] !== void 0) {
312
- cleanMetadata[key] = rawMetadata[key];
313
- }
314
- }
315
- if (rawMetadata.price_breakdown) {
316
- cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
317
- }
318
- if (rawMetadata.is_rule !== void 0) {
319
- cleanMetadata.is_rule = rawMetadata.is_rule;
320
- }
321
- return {
322
- ...submitProduct,
323
- ...bookingUid ? { booking_uid: bookingUid } : {},
324
- product_option_item: formatSubmitOptionItems(submitProduct.product_option_item),
325
- discount_list: submitProduct.discount_list || [],
326
- product_bundle: formatSubmitBundleItems(submitProduct.product_bundle),
327
- metadata: cleanMetadata,
328
- // 出站兼容:后端消费 payment_price 字段,这里从 selling_price 直接派生。
329
- // 新语义下 selling_price 是 composite(含 option/bundle),payment_price 同语义。
330
- payment_price: submitProduct.selling_price
331
- };
332
- }
333
- var SUBMIT_BOOKING_METADATA_WHITELIST = [
334
- "unique_identification_number",
335
- "collect_pax"
336
- ];
337
- function normalizeSubmitBooking(booking) {
338
- const rawMetadata = booking.metadata || {};
339
- const cleanMetadata = {};
340
- for (const key of SUBMIT_BOOKING_METADATA_WHITELIST) {
341
- if (rawMetadata[key] !== void 0) {
342
- cleanMetadata[key] = rawMetadata[key];
343
- }
344
- }
345
- return {
346
- ...booking,
347
- metadata: cleanMetadata
348
- };
349
- }
350
- var DEFAULT_TABLE_OCCUPANCY_DURATION = 20;
351
- function resolveTableOccupancyDuration(tempOrder) {
352
- var _a, _b, _c, _d;
353
- const metadata = tempOrder.metadata || {};
354
- const candidates = [
355
- metadata.table_occupancy_duration,
356
- metadata.booking_duration,
357
- metadata.table_duration,
358
- metadata.duration,
359
- (_a = metadata.table_config) == null ? void 0 : _a.occupancy_duration,
360
- (_b = metadata.tableConfig) == null ? void 0 : _b.occupancy_duration,
361
- (_c = metadata.resource_config) == null ? void 0 : _c.occupancy_duration,
362
- (_d = metadata.resourceConfig) == null ? void 0 : _d.occupancy_duration
363
- ];
364
- for (const value of candidates) {
365
- const duration = Number(value);
366
- if (Number.isFinite(duration) && duration > 0) {
367
- return Math.floor(duration);
368
- }
369
- }
370
- return DEFAULT_TABLE_OCCUPANCY_DURATION;
371
- }
372
- function normalizeSubmitCollectPaxValue(value) {
373
- const n = Number(value);
374
- return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
375
- }
376
- function resolveSubmitCollectPax(tempOrder) {
377
- var _a;
378
- return normalizeSubmitCollectPaxValue((_a = tempOrder.metadata) == null ? void 0 : _a.collect_pax);
379
- }
380
- function createDefaultTempOrder(params) {
381
- const summary = params.summary || (0, import_utils.createEmptySummary)();
382
- return {
383
- order_id: null,
384
- relation_id: void 0,
385
- table_form_id: void 0,
386
- resource_id: void 0,
387
- order_number: "",
388
- shop_order_number: "",
389
- type: "appointment_booking",
390
- business_code: "appointment_booking",
391
- platform: "h5",
392
- sales_channel: "my_pisel",
393
- order_sales_channel: "online_store",
394
- status: "normal",
395
- payment_status: "payment_processing",
396
- shipping_status: "unfulfilled",
397
- customer_id: null,
398
- customer_name: "",
399
- country_calling_code: "",
400
- phone: "",
401
- email: "",
402
- is_price_include_tax: 1,
403
- tax_title: "",
404
- tax_country_code: "",
405
- currency_code: "",
406
- currency_symbol: "",
407
- currency_format: "symbol_first",
408
- is_deposit: 0,
409
- deposit_amount: "0.00",
410
- shop_discount: "0.00",
411
- surcharge_fee: "0.00",
412
- note: "",
413
- schedule_date: params.now,
414
- created_at: params.now,
415
- products: [],
416
- bookings: [],
417
- payments: [],
418
- surcharges: [],
419
- discount_list: [],
420
- relation_forms: [],
421
- contacts: [],
422
- contacts_info: [],
423
- holder: null,
424
- summary,
425
- metadata: {}
426
- };
427
- }
428
- function buildSubmitPayload(params) {
429
- const {
430
- tempOrder,
431
- cacheId,
432
- now = /* @__PURE__ */ new Date(),
433
- platform,
434
- businessCode,
435
- channel,
436
- type,
437
- enhance
438
- } = params;
439
- const scheduleDate = tempOrder.schedule_date || tempOrder.created_at || formatDateTime(now);
440
- const summary = tempOrder.summary || (0, import_utils.createEmptySummary)();
441
- const relationId = tempOrder.relation_id;
442
- const tableFormId = tempOrder.table_form_id;
443
- const bookingUuid = createUuidV4();
444
- const bookingStart = (0, import_dayjs.default)(now);
445
- const bookingDuration = resolveTableOccupancyDuration(tempOrder);
446
- const bookingEnd = bookingStart.add(bookingDuration, "minute");
447
- const bookings = relationId && tableFormId ? [{
448
- relation_id: 0,
449
- form_id: 0,
450
- start_time: bookingStart.format("HH:mm"),
451
- start_date: bookingStart.format("YYYY-MM-DD"),
452
- end_time: bookingEnd.format("HH:mm"),
453
- end_date: bookingEnd.format("YYYY-MM-DD"),
454
- duration: bookingDuration,
455
- metadata: {
456
- unique_identification_number: bookingUuid,
457
- collect_pax: resolveSubmitCollectPax(tempOrder)
458
- },
459
- select_date: bookingStart.format("YYYY-MM-DD"),
460
- is_all: false,
461
- like_status: "common",
462
- schedule_id: 0,
463
- relation_type: "",
464
- number: 1
465
- }] : tempOrder.bookings || [];
466
- const formRecordIds = relationId && tableFormId ? [{
467
- form_id: tableFormId,
468
- form_record_id: relationId
469
- }] : void 0;
470
- const { created_at: _createdAt, summary: _summary, surcharges: _surcharges, ...tempOrderRest } = tempOrder;
471
- const payload = {
472
- ...tempOrderRest,
473
- platform: normalizeSubmitPlatform(platform ?? tempOrder.platform),
474
- request_unique_idempotency_token: cacheId,
475
- type: type ?? tempOrder.type ?? "table-order",
476
- business_code: businessCode ?? tempOrder.business_code ?? "table-order",
477
- sales_channel: tempOrder.sales_channel || "my_pisel",
478
- order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
479
- status: tempOrder.status || "normal",
480
- payment_status: tempOrder.payment_status || "payment_processing",
481
- // shipping_status: tempOrder.shipping_status || 'unfulfilled',
482
- is_price_include_tax: tempOrder.is_price_include_tax ?? 1,
483
- currency_format: tempOrder.currency_format || "symbol_first",
484
- is_deposit: tempOrder.is_deposit ?? 0,
485
- deposit_amount: tempOrder.deposit_amount || "0.00",
486
- shop_discount: tempOrder.shop_discount || "0.00",
487
- surcharge_fee: summary.surcharge_fee || tempOrder.surcharge_fee || "0.00",
488
- note: tempOrder.note || "",
489
- schedule_date: scheduleDate,
490
- bookings: bookings.map((booking) => normalizeSubmitBooking(booking)),
491
- payments: tempOrder.payments || [],
492
- // discount_list: tempOrder.discount_list || [],
493
- relation_forms: tempOrder.relation_forms || [],
494
- form_record_ids: formRecordIds,
495
- // contacts: tempOrder.contacts || [],
496
- contacts_info: tempOrder.contacts_info || [],
497
- // holder: tempOrder.holder || null,
498
- // summary,
499
- metadata: (() => {
500
- const {
501
- collect_pax: _collectPax,
502
- table_occupancy_duration: _tableOccupancyDuration,
503
- ...rest
504
- } = tempOrder.metadata || {};
505
- return { ...rest };
506
- })(),
507
- products: (tempOrder.products || []).map(
508
- (product) => normalizeSubmitProduct(product)
509
- )
510
- };
511
- return enhance ? enhance(payload, { tempOrder, bookingUuid, now }) : payload;
512
- }
513
- function filterProductsForScanOrderMore(products) {
514
- return (products || []).filter((p) => {
515
- var _a;
516
- return ((_a = p.metadata) == null ? void 0 : _a.is_rule) !== true;
517
- });
518
- }
519
- function formatV1Product(products) {
520
- return products.map((product) => {
521
- return {
522
- bundle: product.product_bundle,
523
- key: product.product_id,
524
- option: product.product_option_item,
525
- product_id: product.product_id,
526
- product_variant_id: product.product_variant_id,
527
- num: product.num,
528
- note: String(product.note ?? ""),
529
- rowKey: product.product_id,
530
- session: null,
531
- unique: createUuidV4()
532
- };
533
- });
534
- }
535
68
  // Annotate the CommonJS export names for ESM import in node:
536
69
  0 && (module.exports = {
537
- buildSubmitPayload,
538
- composeLinePrice,
539
- createDefaultOrderRulesHooks,
540
- createDefaultTempOrder,
541
- createEmptySummary,
542
- createUuidV4,
543
- filterProductsForScanOrderMore,
544
- formatDateTime,
545
- formatV1Product,
546
70
  generateDuration,
547
71
  getAllDiscountList,
548
- isTempOrder,
549
- mergeRelationForms,
550
- normalizeSubmitBooking,
551
- normalizeSubmitCollectPaxValue,
552
- resolveSubmitCollectPax,
553
- sumOptionUnitPrice
72
+ mergeRelationForms
554
73
  });
@@ -1,5 +1,5 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
- import { RequestPlugin } from '../../plugins';
2
+ import { RequestPlugin, WindowPlugin } from '../../plugins';
3
3
  import { BaseModule } from '../BaseModule';
4
4
  import { PaymentModuleAPI, PaymentMethod, PaymentOrder, PaymentItem, PaymentItemInput, PaymentUpdateFields, PushOrderParams, CashPayment, EftposPayment, WalletPassPayment, RoundingRule, RoundingInterval, RoundingResult } from './types';
5
5
  export * from './types';
@@ -21,6 +21,7 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
21
21
  request: RequestPlugin;
22
22
  private app;
23
23
  private store;
24
+ window: WindowPlugin;
24
25
  private dbManager;
25
26
  private logger;
26
27
  protected otherParams: any;
@@ -70,6 +70,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
70
70
  this.otherParams = options.otherParams || {};
71
71
  this.request = core.getPlugin("request");
72
72
  const appPlugin = core.getPlugin("app");
73
+ this.window = core.getPlugin("window");
73
74
  if (!this.request) {
74
75
  throw new Error("支付模块需要 request 插件支持");
75
76
  }
@@ -25,6 +25,9 @@ __export(utils_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(utils_exports);
27
27
  var getAvailableMaxAmount = (data) => {
28
+ if (typeof data._available_max_amount === "number") {
29
+ return data._available_max_amount;
30
+ }
28
31
  return data.tag !== "point_card" ? data.available_max_amount : data == null ? void 0 : data.recommended_usage_amount;
29
32
  };
30
33
  var formatWalletPassList2PreparePayments = (list) => {
@@ -9,6 +9,7 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
9
9
  private userIdentificationCodes;
10
10
  private searchResults;
11
11
  private walletParams;
12
+ private walletInitData;
12
13
  constructor(paymentModule: PaymentModule);
13
14
  /**
14
15
  * 发送事件的辅助方法
@@ -37,7 +38,14 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
37
38
  initializeWalletDataFromBusinessAsync(businessData: WalletInitBusinessData): Promise<{
38
39
  walletRecommendList: WalletRecommendItem[];
39
40
  userIdentificationCodes: UserIdentificationCodeItem[];
41
+ transformList: any[];
42
+ noApplicableVoucher: any[];
43
+ products: any[];
40
44
  }>;
45
+ /**
46
+ * 获取订单基础详情
47
+ */
48
+ getOrderBasicDetailAsync(orderId: string): Promise<any>;
41
49
  /**
42
50
  * 初始化钱包数据
43
51
  * 先获取推荐列表,再获取用户识别码列表(顺序执行)
@@ -45,6 +53,9 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
45
53
  initializeWalletDataAsync(baseParams: WalletDeductionRecommendParams): Promise<{
46
54
  walletRecommendList: WalletRecommendItem[];
47
55
  userIdentificationCodes: UserIdentificationCodeItem[];
56
+ transformList: any[];
57
+ noApplicableVoucher: any[];
58
+ products: any[];
48
59
  }>;
49
60
  getWalletPassRecommendListAsync(params: WalletDeductionRecommendParams): Promise<WalletRecommendItem[]>;
50
61
  formatWalletPassList2PreparePayments(list: WalletRecommendItem[]): {
@@ -92,6 +103,18 @@ export declare class WalletPassPaymentImpl implements WalletPassPayment {
92
103
  * 清除搜索结果缓存
93
104
  */
94
105
  clearSearchResults(): void;
106
+ /**
107
+ * 获取存储的钱包初始化数据
108
+ */
109
+ getStoredWalletInitData(): {
110
+ transformList: any[];
111
+ noApplicableVoucher: any[];
112
+ products: any[];
113
+ } | null;
114
+ /**
115
+ * 清除存储的钱包初始化数据
116
+ */
117
+ clearStoredWalletInitData(): void;
95
118
  /**
96
119
  * 清除所有缓存数据
97
120
  */