@pisell/pisellos 2.2.291 → 2.2.293

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 (174) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +108 -65
  3. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  4. package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
  5. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  6. package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
  7. package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
  8. package/dist/model/strategy/adapter/itemRule/type.js +19 -1
  9. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  10. package/dist/modules/BookingContext/index.d.ts +3 -0
  11. package/dist/modules/BookingContext/index.js +42 -13
  12. package/dist/modules/BookingContext/types.d.ts +4 -4
  13. package/dist/modules/BookingContext/types.js +3 -3
  14. package/dist/modules/OpenData/types.d.ts +1 -0
  15. package/dist/modules/Order/index.d.ts +18 -3
  16. package/dist/modules/Order/index.js +885 -485
  17. package/dist/modules/Order/salesNotes.d.ts +31 -0
  18. package/dist/modules/Order/salesNotes.js +492 -0
  19. package/dist/modules/Order/types.d.ts +93 -5
  20. package/dist/modules/Order/types.js +5 -0
  21. package/dist/modules/Order/utils.d.ts +12 -0
  22. package/dist/modules/Order/utils.js +96 -31
  23. package/dist/modules/Product/types.d.ts +2 -0
  24. package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
  25. package/dist/modules/ProductList/clientDataVariants.js +216 -0
  26. package/dist/modules/ProductList/index.d.ts +18 -3
  27. package/dist/modules/ProductList/index.js +220 -38
  28. package/dist/modules/ProductList/types.d.ts +10 -0
  29. package/dist/modules/Quotation/index.d.ts +22 -0
  30. package/dist/modules/Quotation/index.js +293 -28
  31. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  32. package/dist/modules/ResourcePlanner/index.js +1 -180
  33. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  34. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  35. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  36. package/dist/modules/ResourcePlanner/planner.js +2111 -958
  37. package/dist/modules/ResourcePlanner/types.d.ts +359 -187
  38. package/dist/modules/ResourcePlanner/types.js +33 -1
  39. package/dist/plugins/request.d.ts +1 -0
  40. package/dist/server/index.d.ts +17 -2
  41. package/dist/server/index.js +1134 -932
  42. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  43. package/dist/server/modules/floor-plan/index.js +240 -98
  44. package/dist/server/modules/menu/index.js +48 -23
  45. package/dist/server/modules/order/index.d.ts +17 -7
  46. package/dist/server/modules/order/index.js +419 -207
  47. package/dist/server/modules/products/index.d.ts +10 -4
  48. package/dist/server/modules/products/index.js +177 -84
  49. package/dist/server/modules/resource/index.js +21 -13
  50. package/dist/server/utils/product.d.ts +1 -1
  51. package/dist/server/utils/product.js +186 -22
  52. package/dist/server/utils/small-ticket.d.ts +9 -1
  53. package/dist/server/utils/small-ticket.js +131 -84
  54. package/dist/solution/BaseSales/index.d.ts +26 -3
  55. package/dist/solution/BaseSales/index.js +1384 -905
  56. package/dist/solution/BaseSales/types.d.ts +2 -0
  57. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  58. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
  59. package/dist/solution/BaseSales/utils.js +6 -3
  60. package/dist/solution/BookingByStep/index.d.ts +4 -4
  61. package/dist/solution/BookingTicket/index.d.ts +1 -1
  62. package/dist/solution/BookingTicket/index.js +4 -2
  63. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  64. package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
  65. package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
  66. package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
  67. package/dist/solution/RegisterAndLogin/config.js +95 -40
  68. package/dist/solution/RegisterAndLogin/index.js +4 -1
  69. package/dist/solution/ScanOrder/index.d.ts +1 -0
  70. package/dist/solution/ScanOrder/index.js +31 -27
  71. package/dist/solution/ScanOrder/types.d.ts +2 -0
  72. package/dist/solution/ScanOrder/utils.d.ts +1 -0
  73. package/dist/solution/ScanOrder/utils.js +8 -3
  74. package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
  75. package/dist/solution/UnifiedBookingSales/index.js +3877 -963
  76. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  77. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  78. package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
  79. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  80. package/dist/solution/VenueBooking/index.d.ts +3 -0
  81. package/dist/solution/VenueBooking/index.js +549 -497
  82. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  83. package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
  84. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  85. package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
  86. package/dist/utils/platform.d.ts +8 -0
  87. package/dist/utils/platform.js +15 -0
  88. package/lib/core/index.d.ts +7 -0
  89. package/lib/core/index.js +20 -2
  90. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
  92. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
  93. package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
  94. package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
  95. package/lib/model/strategy/adapter/itemRule/type.js +19 -1
  96. package/lib/modules/BookingContext/index.d.ts +3 -0
  97. package/lib/modules/BookingContext/index.js +35 -8
  98. package/lib/modules/BookingContext/types.d.ts +4 -4
  99. package/lib/modules/BookingContext/types.js +3 -3
  100. package/lib/modules/OpenData/types.d.ts +1 -0
  101. package/lib/modules/Order/index.d.ts +18 -3
  102. package/lib/modules/Order/index.js +325 -28
  103. package/lib/modules/Order/salesNotes.d.ts +31 -0
  104. package/lib/modules/Order/salesNotes.js +382 -0
  105. package/lib/modules/Order/types.d.ts +93 -5
  106. package/lib/modules/Order/types.js +4 -0
  107. package/lib/modules/Order/utils.d.ts +12 -0
  108. package/lib/modules/Order/utils.js +85 -16
  109. package/lib/modules/Product/types.d.ts +2 -0
  110. package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
  111. package/lib/modules/ProductList/clientDataVariants.js +204 -0
  112. package/lib/modules/ProductList/index.d.ts +18 -3
  113. package/lib/modules/ProductList/index.js +137 -8
  114. package/lib/modules/ProductList/types.d.ts +10 -0
  115. package/lib/modules/Quotation/index.d.ts +22 -0
  116. package/lib/modules/Quotation/index.js +158 -11
  117. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  118. package/lib/modules/ResourcePlanner/index.js +9 -129
  119. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  120. package/lib/modules/ResourcePlanner/localClock.js +205 -0
  121. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  122. package/lib/modules/ResourcePlanner/planner.js +1807 -783
  123. package/lib/modules/ResourcePlanner/types.d.ts +359 -187
  124. package/lib/modules/ResourcePlanner/types.js +13 -1
  125. package/lib/plugins/request.d.ts +1 -0
  126. package/lib/server/index.d.ts +17 -2
  127. package/lib/server/index.js +149 -21
  128. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  129. package/lib/server/modules/floor-plan/index.js +60 -7
  130. package/lib/server/modules/menu/index.js +26 -4
  131. package/lib/server/modules/order/index.d.ts +17 -7
  132. package/lib/server/modules/order/index.js +194 -57
  133. package/lib/server/modules/products/index.d.ts +10 -4
  134. package/lib/server/modules/products/index.js +93 -23
  135. package/lib/server/modules/resource/index.js +12 -2
  136. package/lib/server/utils/product.d.ts +1 -1
  137. package/lib/server/utils/product.js +163 -3
  138. package/lib/server/utils/small-ticket.d.ts +9 -1
  139. package/lib/server/utils/small-ticket.js +123 -79
  140. package/lib/solution/BaseSales/index.d.ts +26 -3
  141. package/lib/solution/BaseSales/index.js +396 -70
  142. package/lib/solution/BaseSales/types.d.ts +2 -0
  143. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
  144. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
  145. package/lib/solution/BaseSales/utils.js +3 -0
  146. package/lib/solution/BookingByStep/index.d.ts +4 -4
  147. package/lib/solution/BookingTicket/index.d.ts +1 -1
  148. package/lib/solution/BookingTicket/index.js +2 -1
  149. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  150. package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
  151. package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
  152. package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
  153. package/lib/solution/RegisterAndLogin/config.js +49 -8
  154. package/lib/solution/RegisterAndLogin/index.js +4 -1
  155. package/lib/solution/ScanOrder/index.d.ts +1 -0
  156. package/lib/solution/ScanOrder/index.js +5 -1
  157. package/lib/solution/ScanOrder/types.d.ts +2 -0
  158. package/lib/solution/ScanOrder/utils.d.ts +1 -0
  159. package/lib/solution/ScanOrder/utils.js +4 -0
  160. package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
  161. package/lib/solution/UnifiedBookingSales/index.js +2592 -424
  162. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  163. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
  164. package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
  165. package/lib/solution/UnifiedBookingSales/types.js +4 -6
  166. package/lib/solution/VenueBooking/index.d.ts +3 -0
  167. package/lib/solution/VenueBooking/index.js +33 -9
  168. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
  169. package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
  170. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
  171. package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
  172. package/lib/utils/platform.d.ts +8 -0
  173. package/lib/utils/platform.js +22 -0
  174. package/package.json +1 -1
@@ -30,8 +30,6 @@ var LABELS = {
30
30
  pickUpTime: 'Pick-up time',
31
31
  asap: 'ASAP',
32
32
  cash: 'Cash',
33
- cashReceived: 'Cash received',
34
- changeDue: 'Change due',
35
33
  eftpos: 'Eftpos',
36
34
  wallet: 'Wallet',
37
35
  giftCard: 'Gift card',
@@ -42,6 +40,7 @@ var LABELS = {
42
40
  orderDiscount: 'Order discount',
43
41
  manualDiscount: 'Manual discount',
44
42
  payProcessingFee: 'Pay processing fee',
43
+ surchargeIncluded: 'Surcharge(Included)',
45
44
  rounding: 'Rounding',
46
45
  gross: 'Gross',
47
46
  tare: 'Tare'
@@ -58,8 +57,6 @@ var LABELS = {
58
57
  pickUpTime: '取餐时间',
59
58
  asap: '尽快',
60
59
  cash: '现金支付',
61
- cashReceived: '收取现金',
62
- changeDue: '找零',
63
60
  eftpos: '刷卡支付',
64
61
  wallet: '钱包支付',
65
62
  giftCard: '礼品卡',
@@ -70,6 +67,7 @@ var LABELS = {
70
67
  orderDiscount: '整单折扣',
71
68
  manualDiscount: '手动折扣',
72
69
  payProcessingFee: '支付手续费',
70
+ surchargeIncluded: '手续费(已含)',
73
71
  rounding: '抹零',
74
72
  gross: '重量',
75
73
  tare: '去皮'
@@ -86,8 +84,6 @@ var LABELS = {
86
84
  pickUpTime: '取餐時間',
87
85
  asap: '盡快',
88
86
  cash: '現金支付',
89
- cashReceived: '收取現金',
90
- changeDue: '找零',
91
87
  eftpos: '刷卡支付',
92
88
  wallet: '錢包支付',
93
89
  giftCard: '禮品卡',
@@ -98,17 +94,10 @@ var LABELS = {
98
94
  orderDiscount: '整單折扣',
99
95
  manualDiscount: '手動折扣',
100
96
  payProcessingFee: '支付手續費',
97
+ surchargeIncluded: '手續費(已含)',
101
98
  rounding: '抹零',
102
99
  gross: '重量',
103
100
  tare: '去皮'
104
- },
105
- ja: {
106
- cashReceived: 'お預かり',
107
- changeDue: 'お釣り'
108
- },
109
- pt: {
110
- cashReceived: 'Dinheiro recebido',
111
- changeDue: 'Troco'
112
101
  }
113
102
  };
114
103
  export function buildSmallTicketData(params) {
@@ -161,6 +150,11 @@ function buildLocaleData(params) {
161
150
  locale: locale,
162
151
  currencySymbol: currencySymbol
163
152
  }),
153
+ wallets: buildWallets({
154
+ order: order,
155
+ locale: locale,
156
+ currencySymbol: currencySymbol
157
+ }),
164
158
  tickets: Array.isArray(order.tickets) ? order.tickets : [],
165
159
  source_shop: [],
166
160
  refund_data: [],
@@ -173,25 +167,27 @@ function buildBaseData(params) {
173
167
  shopInfo = params.shopInfo,
174
168
  locale = params.locale;
175
169
  var orderNumber = stringify(order.buzzer || order.shop_full_order_number);
176
- return {
170
+ return _objectSpread({
177
171
  shop_name: stringify(shopInfo.name || order.shop_name),
178
172
  note: stringify(order.note),
179
173
  shop_order_number: stringify(order.shop_order_number),
180
174
  order_number: orderNumber,
181
175
  shop_tax_number: stringify(shopInfo.tax_number || order.shop_tax_number),
182
176
  shop_phone: stringify(shopInfo.phone || order.shop_phone),
183
- shop_address: stringify(shopInfo.receipt_address || shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
177
+ shop_address: stringify(shopInfo.address || buildShopAddress(shopInfo) || order.shop_address),
184
178
  original_payment_status: stringify(order.payment_status),
185
179
  is_repeat: 0,
186
180
  buzzer: stringify(order.buzzer || order.pickup_number || ((_order$metadata = order.metadata) === null || _order$metadata === void 0 ? void 0 : _order$metadata.buzzer)),
187
181
  order_no: orderNumber,
188
182
  order_time: formatDateTime(order.created_at || order.sales_time || new Date(), locale)
189
- };
183
+ }, isPresentId(order.updated_at) ? {
184
+ updated_at: formatDateTime(order.updated_at, locale)
185
+ } : {});
190
186
  }
191
187
  function buildProducts(order, locale, productMap) {
192
188
  var products = Array.isArray(order.products) ? order.products : [];
193
189
  return products.map(function (product) {
194
- var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id;
190
+ var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id, _product$metadata, _product$metadata2;
195
191
  var quantity = toNumber((_ref = (_ref2 = (_product$product_quan = product.product_quantity) !== null && _product$product_quan !== void 0 ? _product$product_quan : product.quantity) !== null && _ref2 !== void 0 ? _ref2 : product.num) !== null && _ref !== void 0 ? _ref : 1, 1);
196
192
  var originalPrice = (_ref3 = (_ref4 = (_ref5 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref5 !== void 0 ? _ref5 : product.payment_price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
197
193
  var sellingPrice = (_ref6 = (_ref7 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.payment_price) !== null && _ref7 !== void 0 ? _ref7 : product.price) !== null && _ref6 !== void 0 ? _ref6 : originalPrice;
@@ -220,6 +216,8 @@ function buildProducts(order, locale, productMap) {
220
216
  parentProduct: parentProduct,
221
217
  locale: locale
222
218
  });
219
+ var productUid = firstPresentValue((_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.unique_identification_number, product.unique_identification_number);
220
+ var bookingUid = firstPresentValue(product.booking_uid, (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.booking_uid);
223
221
  var extensionList = buildProductExtensionList({
224
222
  product: product,
225
223
  locale: locale,
@@ -227,14 +225,18 @@ function buildProducts(order, locale, productMap) {
227
225
  quantity: quantity,
228
226
  originalPrice: originalPrice
229
227
  });
230
- return _objectSpread(_objectSpread(_objectSpread({
228
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
231
229
  product_title: productTitle,
232
230
  product_quantity: quantity,
233
231
  selling_price: formatMoney(sellingPrice, currencySymbol),
234
232
  original_price: formatMoney(originalPrice, currencySymbol),
235
233
  total_original_price: formatMoney(new Decimal(toMoneyNumber(originalPrice)).mul(quantity), currencySymbol),
236
234
  extension_list: extensionList
237
- }, options.length ? {
235
+ }, isPresentId(productUid) ? {
236
+ product_uid: productUid
237
+ } : {}), isPresentId(bookingUid) ? {
238
+ booking_uid: bookingUid
239
+ } : {}), options.length ? {
238
240
  options: options
239
241
  } : {}), resolvedVariant ? {
240
242
  variant: resolvedVariant
@@ -615,6 +617,14 @@ function isNonZeroId(value) {
615
617
  function isPresentId(value) {
616
618
  return value !== undefined && value !== null && value !== '';
617
619
  }
620
+ function firstPresentValue() {
621
+ for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
622
+ values[_key] = arguments[_key];
623
+ }
624
+ return values.find(function (value) {
625
+ return isPresentId(value);
626
+ });
627
+ }
618
628
  function isSameId(left, right) {
619
629
  if (!isPresentId(left) || !isPresentId(right)) return false;
620
630
  return String(left) === String(right);
@@ -639,7 +649,7 @@ function formatBundlePrice(bundle, currencySymbol) {
639
649
  return formatMoney(amount, currencySymbol);
640
650
  }
641
651
  function buildFees(params) {
642
- var _ref36, _order$shop_discount, _ref37, _summary$product_orig;
652
+ var _ref36, _order$shop_discount, _firstPresentValue;
643
653
  var order = params.order,
644
654
  shopInfo = params.shopInfo,
645
655
  locale = params.locale,
@@ -686,12 +696,13 @@ function buildFees(params) {
686
696
  });
687
697
  }
688
698
  var productExpectAmount = summary.product_expect_amount || summary.product_amount || order.product_expect_amount;
689
- var productOriginalAmount = (_ref37 = (_summary$product_orig = summary.product_original_amount) !== null && _summary$product_orig !== void 0 ? _summary$product_orig : order.product_original_amount) !== null && _ref37 !== void 0 ? _ref37 : productExpectAmount;
699
+ var productOriginalAmount = (_firstPresentValue = firstPresentValue(summary.product_original_amount, order.product_original_amount)) !== null && _firstPresentValue !== void 0 ? _firstPresentValue : calculateProductOriginalAmount(order);
690
700
  var totalSavingsAmount = new Decimal(toMoneyNumber(productOriginalAmount)).minus(toMoneyNumber(productExpectAmount)).plus(toMoneyNumber(discountAmount));
691
701
  return {
692
702
  fees: fees,
693
703
  countFee: _objectSpread(_objectSpread(_objectSpread(_objectSpread({
694
704
  total_amount: formatMoney(summary.total_amount || order.total_amount, currencySymbol),
705
+ original_item_amount: formatMoney(productOriginalAmount, currencySymbol),
695
706
  product_expect_amount: formatMoney(productExpectAmount, currencySymbol),
696
707
  expect_amount: formatMoney(summary.expect_amount || order.expect_amount || summary.total_amount || order.total_amount, currencySymbol),
697
708
  product_quantity: toNumber(summary.product_quantity || products.reduce(function (sum, product) {
@@ -712,6 +723,14 @@ function buildFees(params) {
712
723
  } : {})
713
724
  };
714
725
  }
726
+ function calculateProductOriginalAmount(order) {
727
+ return normalizeArray(order.products).reduce(function (total, product) {
728
+ var _ref37, _ref38, _product$product_quan2, _ref39, _ref40, _ref41, _product$original_pri2;
729
+ var quantity = toNumber((_ref37 = (_ref38 = (_product$product_quan2 = product.product_quantity) !== null && _product$product_quan2 !== void 0 ? _product$product_quan2 : product.quantity) !== null && _ref38 !== void 0 ? _ref38 : product.num) !== null && _ref37 !== void 0 ? _ref37 : 1, 1);
730
+ var originalPrice = (_ref39 = (_ref40 = (_ref41 = (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : product.selling_price) !== null && _ref41 !== void 0 ? _ref41 : product.payment_price) !== null && _ref40 !== void 0 ? _ref40 : product.price) !== null && _ref39 !== void 0 ? _ref39 : 0;
731
+ return total.plus(new Decimal(toMoneyNumber(originalPrice)).mul(quantity));
732
+ }, new Decimal(0));
733
+ }
715
734
  function buildCustomer(order, locale) {
716
735
  var _order$customer, _order$customer2, _order$customer3, _order$customer4;
717
736
  return [{
@@ -752,6 +771,22 @@ function buildDelivery(order, locale) {
752
771
  }
753
772
  function buildAppointment(order, locale) {
754
773
  var _order$metadata3, _order$metadata4, _order$form_data;
774
+ var bookings = normalizeArray(order.bookings);
775
+ if (bookings.length) {
776
+ return bookings.map(function (booking) {
777
+ var _booking$metadata, _booking$metadata2;
778
+ var snapshot = _objectSpread({}, booking);
779
+ delete snapshot.product_uid;
780
+ delete snapshot.booking_uid;
781
+ var productUid = firstPresentValue(booking.product_uid, (_booking$metadata = booking.metadata) === null || _booking$metadata === void 0 ? void 0 : _booking$metadata.product_uid);
782
+ var bookingUid = firstPresentValue((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.unique_identification_number, booking.booking_uid);
783
+ return _objectSpread(_objectSpread(_objectSpread({}, snapshot), isPresentId(productUid) ? {
784
+ product_uid: productUid
785
+ } : {}), isPresentId(bookingUid) ? {
786
+ booking_uid: bookingUid
787
+ } : {});
788
+ });
789
+ }
755
790
  var tableName = order.table_name || ((_order$metadata3 = order.metadata) === null || _order$metadata3 === void 0 ? void 0 : _order$metadata3.table_name) || ((_order$metadata4 = order.metadata) === null || _order$metadata4 === void 0 || (_order$metadata4 = _order$metadata4.table) === null || _order$metadata4 === void 0 ? void 0 : _order$metadata4.name) || ((_order$form_data = order.form_data) === null || _order$form_data === void 0 ? void 0 : _order$form_data.table_name);
756
791
  if (!tableName) return [];
757
792
  return [{
@@ -774,75 +809,85 @@ function buildPaymentData(params) {
774
809
  return payments.filter(function (payment) {
775
810
  return isPrintablePayment(payment);
776
811
  }).map(function (payment) {
777
- var _payment$amount;
778
- var items = [{
779
- item: paymentMethodName(payment, params.locale),
780
- value: formatMoney((_payment$amount = payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment.origin_amount, params.currencySymbol)
781
- }];
782
- items.push.apply(items, _toConsumableArray(buildCashChangePaymentItems({
812
+ return buildPaymentItems({
783
813
  payment: payment,
784
814
  locale: params.locale,
785
- currencySymbol: params.currencySymbol
786
- })));
787
- var fundRecord = getFundRecord(payment);
788
- if (fundRecord) {
789
- items.push.apply(items, _toConsumableArray(buildFundRecordPaymentItems({
790
- payment: payment,
791
- fundRecord: fundRecord,
792
- locale: params.locale,
793
- currencySymbol: params.currencySymbol
794
- })));
795
- } else {
796
- var _ref38, _payment$remaining_am, _payment$metadata;
797
- var remainingAmount = (_ref38 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref38 !== void 0 ? _ref38 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
798
- if (remainingAmount !== undefined && remainingAmount !== null) {
799
- items.push({
800
- item: label(params.locale, 'remainingAmount'),
801
- value: formatMoney(remainingAmount, params.currencySymbol)
802
- });
803
- }
804
- }
805
- items.push({
806
- item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), params.locale),
807
- value: ''
815
+ currencySymbol: params.currencySymbol,
816
+ includeFundRecordBalance: false
817
+ });
818
+ });
819
+ }
820
+ function buildWallets(params) {
821
+ return normalizeArray(params.order.payments).filter(function (payment) {
822
+ return isPrintablePayment(payment) && !!getFundRecord(payment);
823
+ }).map(function (payment) {
824
+ return buildPaymentItems({
825
+ payment: payment,
826
+ locale: params.locale,
827
+ currencySymbol: params.currencySymbol,
828
+ includeFundRecordBalance: true
808
829
  });
809
- return items;
810
830
  });
811
831
  }
812
- function buildCashChangePaymentItems(params) {
832
+ function buildPaymentItems(params) {
813
833
  var payment = params.payment,
814
834
  locale = params.locale,
815
- currencySymbol = params.currencySymbol;
816
- if (!shouldDisplayCashChange(payment)) return [];
817
- return [{
818
- item: label(locale, 'cashReceived'),
819
- value: formatMoney(payment.metadata.actual_paid_amount, currencySymbol)
820
- }, {
821
- item: label(locale, 'changeDue'),
822
- value: formatMoney(payment.metadata.change_given_amount, currencySymbol)
835
+ currencySymbol = params.currencySymbol,
836
+ includeFundRecordBalance = params.includeFundRecordBalance;
837
+ var serviceFee = getPaymentServiceFee(payment);
838
+ var items = [{
839
+ item: paymentMethodName(payment, locale),
840
+ value: formatMoney(resolveReceiptPaymentAmount(payment, serviceFee), currencySymbol)
823
841
  }];
842
+ if (serviceFee.gt(0)) {
843
+ items.push({
844
+ item: label(locale, 'surchargeIncluded'),
845
+ value: formatMoney(serviceFee, currencySymbol)
846
+ });
847
+ }
848
+ var fundRecord = getFundRecord(payment);
849
+ if (fundRecord) {
850
+ items.push.apply(items, _toConsumableArray(buildFundRecordPaymentItems({
851
+ payment: payment,
852
+ fundRecord: fundRecord,
853
+ locale: locale,
854
+ currencySymbol: currencySymbol,
855
+ includeBalance: includeFundRecordBalance
856
+ })));
857
+ } else {
858
+ var _ref42, _payment$remaining_am, _payment$metadata;
859
+ var remainingAmount = (_ref42 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref42 !== void 0 ? _ref42 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
860
+ if (remainingAmount !== undefined && remainingAmount !== null) {
861
+ items.push({
862
+ item: label(locale, 'remainingAmount'),
863
+ value: formatMoney(remainingAmount, currencySymbol)
864
+ });
865
+ }
866
+ }
867
+ items.push({
868
+ item: formatDateTime(payment.paid_at || payment.created_at || payment.updated_at || new Date(), locale),
869
+ value: ''
870
+ });
871
+ return items;
872
+ }
873
+ function getPaymentServiceFee(payment) {
874
+ return new Decimal(toMoneyNumber(payment.service_fee));
824
875
  }
825
- function shouldDisplayCashChange(payment) {
826
- var _payment$code, _payment$metadata2, _payment$metadata3;
827
- if (stringify(payment.status).toLowerCase() !== 'paid') return false;
828
- var paymentMethod = stringify((_payment$code = payment.code) !== null && _payment$code !== void 0 ? _payment$code : payment.payment_method).toUpperCase();
829
- if (paymentMethod !== 'CASHMANUAL') return false;
830
- var actualPaidAmount = (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.actual_paid_amount;
831
- var changeGivenAmount = (_payment$metadata3 = payment.metadata) === null || _payment$metadata3 === void 0 ? void 0 : _payment$metadata3.change_given_amount;
832
- if (!isNumericAmount(actualPaidAmount) || !isNumericAmount(changeGivenAmount)) return false;
833
- return new Decimal(changeGivenAmount).toDecimalPlaces(2).gt(0);
834
- }
835
- function isNumericAmount(value) {
836
- if (typeof value === 'number') return Number.isFinite(value);
837
- if (typeof value !== 'string') return false;
838
- var normalized = value.trim();
839
- return normalized !== '' && /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(normalized);
876
+ function resolveReceiptPaymentAmount(payment, serviceFee) {
877
+ var _payment$amount;
878
+ var amount = new Decimal(toMoneyNumber((_payment$amount = payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment.origin_amount));
879
+ var hasAmount = payment.amount !== undefined && payment.amount !== null && payment.amount !== '';
880
+ var hasOriginAmount = payment.origin_amount !== undefined && payment.origin_amount !== null && payment.origin_amount !== '';
881
+ if (!hasAmount || !hasOriginAmount || serviceFee.lte(0)) return amount;
882
+ var originAmount = new Decimal(toMoneyNumber(payment.origin_amount));
883
+ return amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
840
884
  }
841
885
  function buildFundRecordPaymentItems(params) {
842
886
  var payment = params.payment,
843
887
  fundRecord = params.fundRecord,
844
888
  locale = params.locale,
845
- currencySymbol = params.currencySymbol;
889
+ currencySymbol = params.currencySymbol,
890
+ includeBalance = params.includeBalance;
846
891
  var items = [];
847
892
  var usingBeforeValue = fundRecord.using_before_value;
848
893
  var usingAfterValue = fundRecord.using_after_value;
@@ -852,13 +897,15 @@ function buildFundRecordPaymentItems(params) {
852
897
  item: label(locale, 'redeemPoints'),
853
898
  value: trimDecimal(usedPoints)
854
899
  });
855
- items.push({
856
- item: label(locale, 'remainingPoints'),
857
- value: trimDecimal(new Decimal(toMoneyNumber(usingAfterValue)))
858
- });
900
+ if (includeBalance) {
901
+ items.push({
902
+ item: label(locale, 'remainingPoints'),
903
+ value: trimDecimal(new Decimal(toMoneyNumber(usingAfterValue)))
904
+ });
905
+ }
859
906
  return items;
860
907
  }
861
- if (usingAfterValue !== undefined && usingAfterValue !== null) {
908
+ if (includeBalance && usingAfterValue !== undefined && usingAfterValue !== null) {
862
909
  items.push({
863
910
  item: label(locale, 'remainingAmount'),
864
911
  value: formatMoney(usingAfterValue, currencySymbol)
@@ -931,12 +978,12 @@ function label(locale, key) {
931
978
  return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
932
979
  }
933
980
  function getLocalizedValue(value, locale) {
934
- var _ref39, _ref40, _ref41, _ref42, _ref43, _ref44, _value$locale2;
981
+ var _ref43, _ref44, _ref45, _ref46, _ref47, _ref48, _value$locale2;
935
982
  if (value === undefined || value === null) return '';
936
983
  if (_typeof(value) !== 'object') return stringify(value);
937
984
  var dashedLocale = locale.replace('_', '-');
938
985
  var underscoredLocale = locale.replace('-', '_');
939
- return stringify((_ref39 = (_ref40 = (_ref41 = (_ref42 = (_ref43 = (_ref44 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref44 !== void 0 ? _ref44 : value[underscoredLocale]) !== null && _ref43 !== void 0 ? _ref43 : value.original) !== null && _ref42 !== void 0 ? _ref42 : value.auto) !== null && _ref41 !== void 0 ? _ref41 : value.default) !== null && _ref40 !== void 0 ? _ref40 : value.en) !== null && _ref39 !== void 0 ? _ref39 : '');
986
+ return stringify((_ref43 = (_ref44 = (_ref45 = (_ref46 = (_ref47 = (_ref48 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref48 !== void 0 ? _ref48 : value[underscoredLocale]) !== null && _ref47 !== void 0 ? _ref47 : value.original) !== null && _ref46 !== void 0 ? _ref46 : value.auto) !== null && _ref45 !== void 0 ? _ref45 : value.default) !== null && _ref44 !== void 0 ? _ref44 : value.en) !== null && _ref43 !== void 0 ? _ref43 : '');
940
987
  }
941
988
  function serviceTypeToLabelKey(serviceType) {
942
989
  var normalized = serviceType.toLowerCase();
@@ -2,7 +2,7 @@ import { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
3
  import { BaseSalesOrderProduct, BaseSalesOrderProductIdentity, BaseSalesPaymentStatus, BaseSalesUpdateOrderProductQuantityParams, BaseSalesCalculateProductBookingPriceParams, BaseSalesPriceRecalculationContextChange, BaseSalesProductBookingPriceResult, BaseSalesQuotationCustomerScopeInfo, BaseSalesScanCodeResult, BaseSalesCashPaymentConfig, BaseSalesPayCashParams, BaseSalesPayCashResult, BaseSalesCommitPaymentMethodParams, BaseSalesCommitPaymentMethodResult, BaseSalesConfirmWalletPaymentResult } from './types';
4
4
  import { OrderModule } from '../../modules/Order';
5
- import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions } from '../../modules/Order/types';
5
+ import type { AddProductBookingInput, AddProductToOrderOptions, LoadSalesDetailParams, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, OrderPaymentSource, SendCustomerPayLinkParams, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, UpdateTempOrderCustomerInput, UpdateOrderBookingParams, UpdateOrderProductParams, OrderTempOrder, OrderSummary, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, ReplaceTempOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from '../../modules/Order/types';
6
6
  import type { SubmitPayloadEnhancer } from '../../modules/Order/utils';
7
7
  import type { Discount } from '../../modules/Discount/types';
8
8
  import { RequestPlugin, WindowPlugin } from '../../plugins';
@@ -129,8 +129,23 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
129
129
  */
130
130
  protected preferAuthoritativeProductQueryPrice(): boolean;
131
131
  private getPriceQuerySchedule;
132
+ private isCustomerUserPriceQuery;
133
+ private getPriceQueryScheduleList;
134
+ private buildPriceQueryPayload;
135
+ private getRawProductPriceSources;
136
+ private rememberRawProductPriceSources;
137
+ private getSelectedProductVariantId;
138
+ /**
139
+ * 将目录原始商品还原为本次选择的 SKU 基线。
140
+ *
141
+ * 这里绝不能复用已评估后的目录商品,否则从命中智能价切回不命中的
142
+ * 日期时会残留旧价格。套餐仅验证所选关系存在,最终仍由 merge 方法把
143
+ * 评估后的套餐价格映射回用户的选择数据。
144
+ */
145
+ private prepareRawProductForPriceQuery;
146
+ private resolveLocalProductForPriceQuery;
132
147
  private loadProductsForPriceQuery;
133
- private loadProductForPriceQuery;
148
+ private resolveProductsForPriceQuery;
134
149
  private getAuthoritativeBundleItems;
135
150
  private findAuthoritativeBundleItem;
136
151
  private getAuthoritativeBundleUnitPrice;
@@ -210,12 +225,20 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
210
225
  getOrderSyncState(): import("../../modules/Order/types").OrderSyncState;
211
226
  getOrderAmountSnapshot(): import("../../modules/Order/types").OrderAmountSnapshot | null;
212
227
  getTempOrderNote(): string;
228
+ getSalesNotes(): SalesNote[];
229
+ createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
230
+ restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
231
+ setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
232
+ removeSalesNote(uuid: string): Promise<void>;
233
+ clearSalesNotes(): Promise<void>;
213
234
  updateTempOrderNote(note: string): string;
214
235
  updateTempOrderNote(note: string, sync: true): Promise<string>;
215
236
  updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
216
237
  updateRemoteOrderNote(orderId: number | string, note: string): void;
217
238
  updateTempOrderShopDiscount(amount: string | number): string;
218
239
  updateTempOrderDepositAmount(amount: string | number): OrderSummary;
240
+ setPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
241
+ setServiceType(serviceType: ShopServiceType): ShopServiceData;
219
242
  updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
220
243
  /** @deprecated OrderModule 不再负责 tempOrder localStorage 持久化。 */
221
244
  setEnableTempOrderPersist(enabled: boolean): void;
@@ -498,7 +521,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
498
521
  getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
499
522
  /** 最近一次促销计算输出的赠品操作 diff。 */
500
523
  getLastGiftActions(): OrderLastGiftActions | null;
501
- getProductList(): Promise<any>;
524
+ getProductList(): Promise<import("../..").ProductData[] | undefined>;
502
525
  getOtherParams(): Record<string, any>;
503
526
  setOtherParams(params: Record<string, any>, { cover }?: {
504
527
  cover?: boolean;