@pisell/pisellos 2.3.38 → 2.3.40

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 (229) hide show
  1. package/dist/core/index.d.ts +0 -2
  2. package/dist/core/index.js +0 -7
  3. package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  4. package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
  5. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  6. package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
  7. package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
  8. package/dist/model/strategy/adapter/promotion/examples.js +0 -99
  9. package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
  10. package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
  11. package/dist/model/strategy/adapter/promotion/type.js +0 -45
  12. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -5
  13. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +3 -6
  14. package/dist/modules/Discount/index.d.ts +1 -0
  15. package/dist/modules/Discount/index.js +40 -11
  16. package/dist/modules/Discount/types.d.ts +1 -0
  17. package/dist/modules/Holder/index.d.ts +48 -0
  18. package/dist/modules/Holder/index.js +640 -0
  19. package/dist/modules/Holder/types.d.ts +123 -0
  20. package/dist/modules/Holder/types.js +1 -0
  21. package/dist/modules/Holder/utils.d.ts +13 -0
  22. package/dist/modules/Holder/utils.js +34 -0
  23. package/dist/modules/OpenData/index.d.ts +0 -2
  24. package/dist/modules/OpenData/index.js +2 -10
  25. package/dist/modules/Order/index.d.ts +11 -28
  26. package/dist/modules/Order/index.js +509 -750
  27. package/dist/modules/Order/types.d.ts +10 -33
  28. package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
  29. package/dist/modules/Order/utils.d.ts +10 -0
  30. package/dist/modules/Order/utils.js +41 -13
  31. package/dist/modules/Payment/index.d.ts +0 -2
  32. package/dist/modules/Payment/index.js +50 -79
  33. package/dist/modules/Payment/types.d.ts +28 -99
  34. package/dist/modules/Payment/types.js +3 -20
  35. package/dist/modules/Payment/walletpass.d.ts +1 -25
  36. package/dist/modules/Payment/walletpass.js +157 -707
  37. package/dist/modules/Product/types.d.ts +1 -0
  38. package/dist/modules/ProductList/index.js +33 -14
  39. package/dist/modules/Quotation/index.d.ts +1 -1
  40. package/dist/modules/Quotation/index.js +2 -2
  41. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  42. package/dist/modules/ResourcePlanner/index.js +181 -0
  43. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  44. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  45. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  46. package/dist/modules/ResourcePlanner/types.js +1 -0
  47. package/dist/modules/Rules/index.d.ts +0 -1
  48. package/dist/modules/Rules/index.js +96 -89
  49. package/dist/modules/SalesSummary/index.js +12 -13
  50. package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
  51. package/dist/modules/ScanOrderLogger/index.js +15 -2
  52. package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
  53. package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
  54. package/dist/modules/Schedule/index.d.ts +3 -1
  55. package/dist/modules/Schedule/index.js +21 -16
  56. package/dist/modules/Summary/utils.js +38 -13
  57. package/dist/modules/index.d.ts +2 -0
  58. package/dist/modules/index.js +3 -1
  59. package/dist/plugins/window.d.ts +1 -0
  60. package/dist/server/index.d.ts +14 -16
  61. package/dist/server/index.js +1148 -1930
  62. package/dist/server/modules/order/index.d.ts +4 -54
  63. package/dist/server/modules/order/index.js +695 -1595
  64. package/dist/server/modules/order/types.d.ts +3 -11
  65. package/dist/server/modules/order/types.js +1 -1
  66. package/dist/solution/BaseSales/index.d.ts +20 -109
  67. package/dist/solution/BaseSales/index.js +481 -1797
  68. package/dist/solution/BaseSales/types.d.ts +0 -52
  69. package/dist/solution/BaseSales/types.js +1 -2
  70. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  71. package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
  72. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  73. package/dist/solution/BookingByStep/index.d.ts +17 -2
  74. package/dist/solution/BookingByStep/index.js +294 -215
  75. package/dist/solution/BookingByStep/types.d.ts +2 -1
  76. package/dist/solution/BookingByStep/types.js +3 -1
  77. package/dist/solution/BookingByStep/utils/capacity.js +17 -1
  78. package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  79. package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
  80. package/dist/solution/BookingTicket/index.d.ts +4 -8
  81. package/dist/solution/BookingTicket/index.js +51 -134
  82. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -6
  83. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  84. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +82 -172
  85. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  86. package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
  87. package/dist/solution/Sales/index.d.ts +0 -1
  88. package/dist/solution/Sales/index.js +2 -10
  89. package/dist/solution/ScanOrder/index.d.ts +26 -14
  90. package/dist/solution/ScanOrder/index.js +1148 -756
  91. package/dist/solution/ScanOrder/types.d.ts +21 -1
  92. package/dist/solution/ScanOrder/utils.d.ts +8 -0
  93. package/dist/solution/ScanOrder/utils.js +66 -25
  94. package/dist/solution/ShopDiscount/index.d.ts +1 -0
  95. package/dist/solution/ShopDiscount/index.js +125 -87
  96. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  97. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  98. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  99. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  100. package/dist/solution/VenueBooking/index.d.ts +39 -11
  101. package/dist/solution/VenueBooking/index.js +1176 -860
  102. package/dist/solution/VenueBooking/types.d.ts +3 -0
  103. package/dist/solution/VenueBooking/utils/resource.js +1 -0
  104. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  105. package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
  106. package/dist/solution/index.d.ts +1 -0
  107. package/dist/solution/index.js +2 -1
  108. package/dist/types/index.d.ts +1 -1
  109. package/lib/core/index.d.ts +0 -2
  110. package/lib/core/index.js +0 -4
  111. package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
  112. package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
  113. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
  114. package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
  115. package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
  116. package/lib/model/strategy/adapter/promotion/examples.js +0 -91
  117. package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
  118. package/lib/model/strategy/adapter/promotion/index.js +0 -2
  119. package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
  120. package/lib/model/strategy/adapter/promotion/type.js +0 -2
  121. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +1 -2
  122. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +1 -2
  123. package/lib/modules/Discount/index.d.ts +1 -0
  124. package/lib/modules/Discount/index.js +9 -0
  125. package/lib/modules/Discount/types.d.ts +1 -0
  126. package/lib/modules/Holder/index.d.ts +48 -0
  127. package/lib/modules/Holder/index.js +402 -0
  128. package/lib/modules/Holder/types.d.ts +123 -0
  129. package/lib/modules/Holder/types.js +17 -0
  130. package/lib/modules/Holder/utils.d.ts +13 -0
  131. package/lib/modules/Holder/utils.js +71 -0
  132. package/lib/modules/OpenData/index.d.ts +0 -2
  133. package/lib/modules/OpenData/index.js +1 -6
  134. package/lib/modules/Order/index.d.ts +11 -28
  135. package/lib/modules/Order/index.js +86 -196
  136. package/lib/modules/Order/types.d.ts +10 -33
  137. package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
  138. package/lib/modules/Order/utils.d.ts +10 -0
  139. package/lib/modules/Order/utils.js +40 -16
  140. package/lib/modules/Payment/index.d.ts +0 -2
  141. package/lib/modules/Payment/index.js +13 -34
  142. package/lib/modules/Payment/types.d.ts +28 -99
  143. package/lib/modules/Payment/types.js +3 -4
  144. package/lib/modules/Payment/walletpass.d.ts +1 -25
  145. package/lib/modules/Payment/walletpass.js +21 -470
  146. package/lib/modules/Product/types.d.ts +1 -0
  147. package/lib/modules/ProductList/index.js +40 -31
  148. package/lib/modules/Quotation/index.d.ts +1 -1
  149. package/lib/modules/Quotation/index.js +2 -2
  150. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  151. package/lib/modules/ResourcePlanner/index.js +148 -0
  152. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  153. package/lib/modules/ResourcePlanner/planner.js +933 -0
  154. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  155. package/lib/modules/ResourcePlanner/types.js +17 -0
  156. package/lib/modules/Rules/index.d.ts +0 -1
  157. package/lib/modules/Rules/index.js +40 -47
  158. package/lib/modules/SalesSummary/index.js +6 -7
  159. package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
  160. package/lib/modules/ScanOrderLogger/index.js +13 -1
  161. package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
  162. package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
  163. package/lib/modules/Schedule/index.d.ts +3 -1
  164. package/lib/modules/Schedule/index.js +10 -8
  165. package/lib/modules/Summary/utils.js +21 -1
  166. package/lib/modules/index.d.ts +2 -0
  167. package/lib/modules/index.js +5 -1
  168. package/lib/plugins/window.d.ts +1 -0
  169. package/lib/server/index.d.ts +14 -16
  170. package/lib/server/index.js +83 -675
  171. package/lib/server/modules/order/index.d.ts +4 -54
  172. package/lib/server/modules/order/index.js +66 -679
  173. package/lib/server/modules/order/types.d.ts +3 -11
  174. package/lib/solution/BaseSales/index.d.ts +20 -109
  175. package/lib/solution/BaseSales/index.js +70 -881
  176. package/lib/solution/BaseSales/types.d.ts +0 -52
  177. package/lib/solution/BaseSales/types.js +1 -2
  178. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
  179. package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
  180. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
  181. package/lib/solution/BookingByStep/index.d.ts +17 -2
  182. package/lib/solution/BookingByStep/index.js +60 -18
  183. package/lib/solution/BookingByStep/types.d.ts +2 -1
  184. package/lib/solution/BookingByStep/types.js +5 -0
  185. package/lib/solution/BookingByStep/utils/capacity.js +20 -1
  186. package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
  187. package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
  188. package/lib/solution/BookingTicket/index.d.ts +4 -8
  189. package/lib/solution/BookingTicket/index.js +19 -64
  190. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -4
  191. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
  192. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +4 -36
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  194. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
  195. package/lib/solution/Sales/index.d.ts +0 -1
  196. package/lib/solution/Sales/index.js +3 -5
  197. package/lib/solution/ScanOrder/index.d.ts +26 -14
  198. package/lib/solution/ScanOrder/index.js +449 -190
  199. package/lib/solution/ScanOrder/types.d.ts +21 -1
  200. package/lib/solution/ScanOrder/utils.d.ts +8 -0
  201. package/lib/solution/ScanOrder/utils.js +31 -0
  202. package/lib/solution/ShopDiscount/index.d.ts +1 -0
  203. package/lib/solution/ShopDiscount/index.js +14 -0
  204. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  205. package/lib/solution/UnifiedBookingSales/index.js +1076 -0
  206. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  207. package/lib/solution/UnifiedBookingSales/types.js +33 -0
  208. package/lib/solution/VenueBooking/index.d.ts +39 -11
  209. package/lib/solution/VenueBooking/index.js +328 -123
  210. package/lib/solution/VenueBooking/types.d.ts +3 -0
  211. package/lib/solution/VenueBooking/utils/resource.js +1 -0
  212. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
  213. package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
  214. package/lib/solution/index.d.ts +1 -0
  215. package/lib/solution/index.js +3 -1
  216. package/lib/types/index.d.ts +1 -1
  217. package/package.json +1 -1
  218. package/dist/modules/Order/payment-utils.d.ts +0 -26
  219. package/dist/modules/Order/payment-utils.js +0 -225
  220. package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  221. package/dist/solution/BookingTicket/utils/weighingProductSku.js +0 -45
  222. package/dist/utils/payment-number.d.ts +0 -9
  223. package/dist/utils/payment-number.js +0 -69
  224. package/lib/modules/Order/payment-utils.d.ts +0 -26
  225. package/lib/modules/Order/payment-utils.js +0 -224
  226. package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +0 -5
  227. package/lib/solution/BookingTicket/utils/weighingProductSku.js +0 -63
  228. package/lib/utils/payment-number.d.ts +0 -9
  229. package/lib/utils/payment-number.js +0 -64
@@ -1,224 +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/Order/payment-utils.ts
20
- var payment_utils_exports = {};
21
- __export(payment_utils_exports, {
22
- ensureOrderPaymentNumber: () => ensureOrderPaymentNumber,
23
- getOrderPaymentIdentityKeys: () => getOrderPaymentIdentityKeys,
24
- hasOrderPaymentIdentityOverlap: () => hasOrderPaymentIdentityOverlap,
25
- isIdentifiedPendingOrderPayment: () => isIdentifiedPendingOrderPayment,
26
- isPendingOrderPayment: () => isPendingOrderPayment,
27
- mergeOrderPaymentListsByIdentity: () => mergeOrderPaymentListsByIdentity,
28
- mergeOrderPaymentRecord: () => mergeOrderPaymentRecord,
29
- mergeOrderPaymentSnapshot: () => mergeOrderPaymentSnapshot,
30
- mergeOrderPaymentTransactions: () => mergeOrderPaymentTransactions,
31
- resolveOrderPaymentIdentity: () => resolveOrderPaymentIdentity
32
- });
33
- module.exports = __toCommonJS(payment_utils_exports);
34
- var PAYMENT_IDENTITY_TYPES = [
35
- "payment_number",
36
- "order_payment_id",
37
- "unique_payment_number"
38
- ];
39
- function normalizePaymentIdentityValue(value) {
40
- if (value === void 0 || value === null || value === "")
41
- return null;
42
- return String(value);
43
- }
44
- function getPaymentIdentityValue(payment, type) {
45
- var _a;
46
- if (type === "unique_payment_number") {
47
- return (_a = payment == null ? void 0 : payment.metadata) == null ? void 0 : _a.unique_payment_number;
48
- }
49
- return payment == null ? void 0 : payment[type];
50
- }
51
- function getOrderPaymentIdentityKeys(payment) {
52
- const record = payment;
53
- if (!record)
54
- return [];
55
- return PAYMENT_IDENTITY_TYPES.flatMap((type) => {
56
- const value = normalizePaymentIdentityValue(getPaymentIdentityValue(record, type));
57
- return value === null ? [] : [`${type}:${value}`];
58
- });
59
- }
60
- function isPendingOrderPayment(payment) {
61
- const record = payment;
62
- return String((record == null ? void 0 : record.status) || "").toLowerCase() === "payment_pending";
63
- }
64
- function isIdentifiedPendingOrderPayment(payment) {
65
- return isPendingOrderPayment(payment) && getOrderPaymentIdentityKeys(payment).length > 0;
66
- }
67
- function hasOrderPaymentIdentityOverlap(left, right) {
68
- const leftKeys = new Set(getOrderPaymentIdentityKeys(left));
69
- if (leftKeys.size === 0)
70
- return false;
71
- return getOrderPaymentIdentityKeys(right).some((key) => leftKeys.has(key));
72
- }
73
- function resolveOrderPaymentIdentity(payments, identity, mode = "payment_number") {
74
- const target = String(identity);
75
- const identityTypes = mode === "payment_number" ? ["payment_number"] : PAYMENT_IDENTITY_TYPES;
76
- const matchesByIndex = /* @__PURE__ */ new Map();
77
- for (const type of identityTypes) {
78
- (payments || []).forEach((payment, index) => {
79
- const value = normalizePaymentIdentityValue(getPaymentIdentityValue(payment, type));
80
- if (value === target && !matchesByIndex.has(index)) {
81
- matchesByIndex.set(index, { index, payment, matchedBy: type });
82
- }
83
- });
84
- }
85
- const matches = [...matchesByIndex.values()];
86
- if (matches.length > 1) {
87
- throw new Error(`支付项身份存在歧义: ${target}`);
88
- }
89
- return matches[0] || null;
90
- }
91
- function ensureOrderPaymentNumber(payment, devicePrefix, createPaymentNumber) {
92
- const existing = normalizePaymentIdentityValue(payment.payment_number);
93
- if (existing)
94
- return { ...payment, payment_number: existing };
95
- const uuid = normalizePaymentIdentityValue(payment.uuid) || createPaymentNumber();
96
- const prefix = normalizePaymentIdentityValue(devicePrefix) || "LOCAL";
97
- return { ...payment, payment_number: `${prefix}_${uuid}` };
98
- }
99
- function mergeOrderPaymentTransactions(current, incoming) {
100
- const records = /* @__PURE__ */ new Map();
101
- const append = (value) => {
102
- if (!Array.isArray(value))
103
- return;
104
- value.forEach((item) => {
105
- const number = item && typeof item === "object" ? String(item.number || "") : "";
106
- const status = item && typeof item === "object" ? item.status : void 0;
107
- if (!number || status !== "success" && status !== "fail")
108
- return;
109
- const previous = records.get(number);
110
- if ((previous == null ? void 0 : previous.status) === "success" && status === "fail")
111
- return;
112
- records.set(number, { number, status });
113
- });
114
- };
115
- append(current);
116
- append(incoming);
117
- return [...records.values()];
118
- }
119
- function mergeOrderPaymentRecord(payment, updates) {
120
- const currentMetadata = payment.metadata || {};
121
- const incomingMetadata = updates.metadata || {};
122
- const transactions = mergeOrderPaymentTransactions(
123
- currentMetadata.transactions,
124
- incomingMetadata.transactions
125
- );
126
- const currentPaid = payment.status === "paid";
127
- const nextStatus = currentPaid && updates.status !== "paid" ? "paid" : updates.status ?? payment.status;
128
- return {
129
- ...payment,
130
- ...updates,
131
- status: nextStatus,
132
- updated_at: updates.updated_at ?? payment.updated_at,
133
- metadata: {
134
- ...currentMetadata,
135
- ...incomingMetadata,
136
- ...transactions.length > 0 || Array.isArray(incomingMetadata.transactions) ? { transactions } : {}
137
- }
138
- };
139
- }
140
- function mergeOrderPaymentSnapshot(current, incoming) {
141
- const currentMetadata = current.metadata || {};
142
- const incomingMetadata = incoming.metadata || {};
143
- const currentUniquePaymentNumber = normalizePaymentIdentityValue(
144
- currentMetadata.unique_payment_number
145
- );
146
- const incomingUniquePaymentNumber = normalizePaymentIdentityValue(
147
- incomingMetadata.unique_payment_number
148
- );
149
- const incomingOrderPaymentId = normalizePaymentIdentityValue(
150
- incoming.order_payment_id
151
- );
152
- const incomingFallbackPrefix = incomingOrderPaymentId ? `os-fallback:payment:order-payment:${incomingOrderPaymentId}` : null;
153
- const incomingUsesDerivedUniquePaymentNumber = Boolean(
154
- incomingUniquePaymentNumber && incomingFallbackPrefix && (incomingUniquePaymentNumber === incomingFallbackPrefix || incomingUniquePaymentNumber.startsWith(`${incomingFallbackPrefix}:conflict:`))
155
- );
156
- const transactions = mergeOrderPaymentTransactions(
157
- currentMetadata.transactions,
158
- incomingMetadata.transactions
159
- );
160
- return {
161
- ...current,
162
- ...incoming,
163
- order_payment_id: normalizePaymentIdentityValue(incoming.order_payment_id) !== null ? incoming.order_payment_id : current.order_payment_id,
164
- payment_number: incoming.payment_number || current.payment_number,
165
- metadata: {
166
- ...currentMetadata,
167
- ...incomingMetadata,
168
- ...incomingUsesDerivedUniquePaymentNumber && currentUniquePaymentNumber ? { unique_payment_number: currentUniquePaymentNumber } : {},
169
- ...transactions.length > 0 ? { transactions } : {}
170
- }
171
- };
172
- }
173
- function compactOrderPaymentList(payments) {
174
- const result = [];
175
- for (const payment of payments) {
176
- const matchingIndexes = result.flatMap((existing, index) => hasOrderPaymentIdentityOverlap(existing, payment) ? [index] : []);
177
- if (matchingIndexes.length === 0) {
178
- result.push(mergeOrderPaymentSnapshot({}, payment));
179
- continue;
180
- }
181
- const firstIndex = matchingIndexes[0];
182
- let merged = result[firstIndex];
183
- for (const index of matchingIndexes.slice(1)) {
184
- merged = mergeOrderPaymentSnapshot(merged, result[index]);
185
- }
186
- result[firstIndex] = mergeOrderPaymentSnapshot(merged, payment);
187
- for (const index of matchingIndexes.slice(1).sort((a, b) => b - a)) {
188
- result.splice(index, 1);
189
- }
190
- }
191
- return result;
192
- }
193
- function mergeOrderPaymentListsByIdentity(existing, incoming, options = {}) {
194
- const existingList = compactOrderPaymentList([...existing || []]);
195
- const incomingList = compactOrderPaymentList([...incoming || []]);
196
- if (options.preserveUnmatchedExisting) {
197
- return compactOrderPaymentList([...existingList, ...incomingList]);
198
- }
199
- const mergedIncoming = incomingList.map((incomingPayment) => {
200
- const matchingExisting = existingList.filter((existingPayment) => hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment));
201
- return matchingExisting.reduce(
202
- (merged, existingPayment) => mergeOrderPaymentSnapshot(existingPayment, merged),
203
- incomingPayment
204
- );
205
- });
206
- const preservedExisting = options.preserveUnmatchedExistingWhen ? existingList.filter((existingPayment) => {
207
- var _a;
208
- return !incomingList.some((incomingPayment) => hasOrderPaymentIdentityOverlap(existingPayment, incomingPayment)) && ((_a = options.preserveUnmatchedExistingWhen) == null ? void 0 : _a.call(options, existingPayment));
209
- }) : [];
210
- return compactOrderPaymentList([...mergedIncoming, ...preservedExisting]);
211
- }
212
- // Annotate the CommonJS export names for ESM import in node:
213
- 0 && (module.exports = {
214
- ensureOrderPaymentNumber,
215
- getOrderPaymentIdentityKeys,
216
- hasOrderPaymentIdentityOverlap,
217
- isIdentifiedPendingOrderPayment,
218
- isPendingOrderPayment,
219
- mergeOrderPaymentListsByIdentity,
220
- mergeOrderPaymentRecord,
221
- mergeOrderPaymentSnapshot,
222
- mergeOrderPaymentTransactions,
223
- resolveOrderPaymentIdentity
224
- });
@@ -1,5 +0,0 @@
1
- /**
2
- * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
3
- * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
4
- */
5
- export declare function buildProductSkuFromCacheItem(cacheItem: Record<string, any> | null | undefined): Record<string, any> | undefined;
@@ -1,63 +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/solution/BookingTicket/utils/weighingProductSku.ts
20
- var weighingProductSku_exports = {};
21
- __export(weighingProductSku_exports, {
22
- buildProductSkuFromCacheItem: () => buildProductSkuFromCacheItem
23
- });
24
- module.exports = __toCommonJS(weighingProductSku_exports);
25
- var WEIGHT_UNIT_MAP = {
26
- KILOGRAMS: "kg",
27
- GRAMS: "g",
28
- POUNDS: "lb",
29
- OUNCES: "oz"
30
- };
31
- function isRecord(value) {
32
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
33
- }
34
- function buildProductSkuFromCacheItem(cacheItem) {
35
- var _a, _b, _c, _d;
36
- const currentSku = isRecord(cacheItem == null ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : void 0;
37
- const weighing = isRecord((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.weighing) ? (_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.weighing : void 0;
38
- const hasRuntimeWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku == null ? void 0 : currentSku.weight) !== void 0 || (currentSku == null ? void 0 : currentSku.net_weight) !== void 0 || (currentSku == null ? void 0 : currentSku.weight_source) !== void 0);
39
- const isWeighingSku = Number((currentSku == null ? void 0 : currentSku.open_sold_weight) || 0) === 1;
40
- if (!isWeighingSku && !weighing)
41
- return void 0;
42
- if (hasRuntimeWeighingSku)
43
- return { ...currentSku };
44
- if (!weighing)
45
- return currentSku ? { ...currentSku } : void 0;
46
- return {
47
- ...currentSku || {},
48
- open_sold_weight: 1,
49
- unit_data_snapshot: weighing.scalePriceProduct,
50
- unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
51
- unit_weight: weighing.unit_weight ?? "1.000",
52
- unit_price: weighing.unit_price,
53
- weight_source: weighing.mode,
54
- tare_name: ((_c = weighing.tare) == null ? void 0 : _c.label) ?? "",
55
- tare_weight: ((_d = weighing.tare) == null ? void 0 : _d.value) ?? 0,
56
- weight: weighing.weight ?? 0,
57
- net_weight: weighing.net_weight ?? 0
58
- };
59
- }
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- buildProductSkuFromCacheItem
63
- });
@@ -1,9 +0,0 @@
1
- export type PaymentNumberAppDataGetter = (key: string) => unknown;
2
- /**
3
- * Resolve the synchronous fallback without caching runtime device data.
4
- */
5
- export declare function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData: PaymentNumberAppDataGetter): string;
6
- /**
7
- * Resolve the latest device segment when a new payment number is generated.
8
- */
9
- export declare function resolvePaymentNumberDevicePrefix(getAppData: PaymentNumberAppDataGetter): Promise<string>;
@@ -1,64 +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/utils/payment-number.ts
20
- var payment_number_exports = {};
21
- __export(payment_number_exports, {
22
- resolvePaymentNumberDevicePrefix: () => resolvePaymentNumberDevicePrefix,
23
- resolvePaymentNumberDevicePrefixFromDeviceId: () => resolvePaymentNumberDevicePrefixFromDeviceId
24
- });
25
- module.exports = __toCommonJS(payment_number_exports);
26
- function normalizeNonEmptyString(value) {
27
- if (value === void 0 || value === null)
28
- return null;
29
- if (typeof value !== "string" && typeof value !== "number")
30
- return null;
31
- if (typeof value === "number" && !Number.isFinite(value))
32
- return null;
33
- const normalized = String(value).trim();
34
- return normalized || null;
35
- }
36
- function resolvePaymentNumberDevicePrefixFromDeviceId(getAppData) {
37
- try {
38
- const deviceId = normalizeNonEmptyString(getAppData("device_id"));
39
- if (deviceId && deviceId !== "0")
40
- return deviceId.slice(-2);
41
- } catch {
42
- }
43
- return "LOCAL";
44
- }
45
- async function resolvePaymentNumberDevicePrefix(getAppData) {
46
- try {
47
- const getAsyncIotDeviceInfo = getAppData("async_iot_device_info");
48
- if (typeof getAsyncIotDeviceInfo === "function") {
49
- const info = await getAsyncIotDeviceInfo();
50
- const shortNumber = normalizeNonEmptyString(
51
- info == null ? void 0 : info.short_number
52
- );
53
- if (shortNumber && shortNumber !== "0")
54
- return shortNumber;
55
- }
56
- } catch {
57
- }
58
- return resolvePaymentNumberDevicePrefixFromDeviceId(getAppData);
59
- }
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- resolvePaymentNumberDevicePrefix,
63
- resolvePaymentNumberDevicePrefixFromDeviceId
64
- });