@pisell/pisellos 2.2.168 → 2.2.169

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 (43) hide show
  1. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +51 -15
  2. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  3. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +26 -2
  4. package/dist/modules/Customer/index.d.ts +6 -0
  5. package/dist/modules/Customer/index.js +122 -77
  6. package/dist/modules/Customer/types.d.ts +2 -0
  7. package/dist/modules/Order/index.d.ts +2 -1
  8. package/dist/modules/Order/index.js +47 -7
  9. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  10. package/dist/modules/Order/utils/manualProductDiscount.js +212 -0
  11. package/dist/modules/Order/utils.d.ts +4 -0
  12. package/dist/modules/Order/utils.js +24 -9
  13. package/dist/modules/Rules/index.d.ts +4 -0
  14. package/dist/modules/Rules/index.js +26 -10
  15. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +37 -6
  16. package/dist/solution/BaseSales/utils.js +11 -2
  17. package/dist/solution/BookingByStep/index.d.ts +1 -1
  18. package/dist/solution/BookingTicket/index.d.ts +1 -1
  19. package/dist/solution/BookingTicket/index.js +4 -4
  20. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -1
  21. package/dist/solution/ScanOrder/utils.js +11 -2
  22. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +42 -9
  23. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +11 -1
  24. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +22 -1
  25. package/lib/modules/Customer/index.d.ts +6 -0
  26. package/lib/modules/Customer/index.js +18 -3
  27. package/lib/modules/Customer/types.d.ts +2 -0
  28. package/lib/modules/Order/index.d.ts +2 -1
  29. package/lib/modules/Order/index.js +46 -3
  30. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  31. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  32. package/lib/modules/Order/utils.d.ts +4 -0
  33. package/lib/modules/Order/utils.js +45 -9
  34. package/lib/modules/Rules/index.d.ts +4 -0
  35. package/lib/modules/Rules/index.js +22 -14
  36. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +42 -4
  37. package/lib/solution/BaseSales/utils.js +10 -2
  38. package/lib/solution/BookingByStep/index.d.ts +1 -1
  39. package/lib/solution/BookingTicket/index.d.ts +1 -1
  40. package/lib/solution/BookingTicket/index.js +2 -2
  41. package/lib/solution/BookingTicket/utils/addProductDecision.js +3 -1
  42. package/lib/solution/ScanOrder/utils.js +10 -2
  43. package/package.json +1 -1
@@ -22,6 +22,7 @@ __export(transformBaseProductToOrderProduct_exports, {
22
22
  transformBaseProductToOrderProduct: () => transformBaseProductToOrderProduct
23
23
  });
24
24
  module.exports = __toCommonJS(transformBaseProductToOrderProduct_exports);
25
+ var import_manualProductDiscount = require("../../../modules/Order/utils/manualProductDiscount");
25
26
  function toNumber(value, fallback = 0) {
26
27
  const parsedValue = Number(value);
27
28
  if (!Number.isFinite(parsedValue))
@@ -87,7 +88,7 @@ function findVariantById(origin, variantId) {
87
88
  return variants.find((variant) => Number(variant == null ? void 0 : variant.id) === variantId) || null;
88
89
  }
89
90
  function transformBaseProductToOrderProduct(params) {
90
- var _a, _b, _c;
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
91
92
  const { payload, fallbackProductId = null } = params;
92
93
  if (!payload || typeof payload !== "object")
93
94
  return null;
@@ -124,6 +125,39 @@ function transformBaseProductToOrderProduct(params) {
124
125
  hasPriceOverride
125
126
  );
126
127
  const uniqueIdentificationNumber = payload.unique_identification_number ?? payload.unique;
128
+ const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
129
+ const originTotal = (0, import_manualProductDiscount.resolveManualDiscountOriginTotal)({
130
+ originTotal: payload.origin_total,
131
+ extendOriginTotal: (_d = payload._extend) == null ? void 0 : _d.origin_total,
132
+ originExtendOriginTotal: (_e = origin == null ? void 0 : origin._extend) == null ? void 0 : _e.origin_total,
133
+ sourceExtendOriginTotal: (_f = sourceProduct == null ? void 0 : sourceProduct._extend) == null ? void 0 : _f.origin_total,
134
+ catalogUnitPrice: (origin == null ? void 0 : origin.base_price) ?? (origin == null ? void 0 : origin.price) ?? (sourceProduct == null ? void 0 : sourceProduct.base_price) ?? (sourceProduct == null ? void 0 : sourceProduct.price),
135
+ quantity: resolvedQuantity
136
+ });
137
+ const sellingTotal = Number(
138
+ payload.line_total ?? payload.total ?? ((_g = payload._extend) == null ? void 0 : _g.total) ?? lineCompositeTotal
139
+ );
140
+ const discountReason = (0, import_manualProductDiscount.resolveManualDiscountReasonFromSources)({
141
+ discountReason: payload.discount_reason,
142
+ extendDiscountReason: (_h = payload._extend) == null ? void 0 : _h.discount_reason,
143
+ originExtendDiscountReason: (_i = origin == null ? void 0 : origin._extend) == null ? void 0 : _i.discount_reason
144
+ });
145
+ const lineOriginalPrice = hasPriceOverride && Number.isFinite(originTotal) ? toPriceString(originTotal) : lineCompositeTotal;
146
+ const manualDiscountList = (0, import_manualProductDiscount.shouldBuildManualProductDiscount)({
147
+ hasPriceOverride,
148
+ originTotal,
149
+ sellingTotal
150
+ }) ? (0, import_manualProductDiscount.mergeManualProductDiscountIntoList)(
151
+ payload.discount_list,
152
+ (0, import_manualProductDiscount.buildManualProductDiscountItem)({
153
+ originTotal: Number.isFinite(originTotal) ? originTotal : Number(lineOriginalPrice),
154
+ sellingTotal: Number.isFinite(sellingTotal) ? sellingTotal : Number(lineCompositeTotal),
155
+ quantity: resolvedQuantity,
156
+ message: discountReason,
157
+ discountway: (_j = payload._extend) == null ? void 0 : _j.discountway,
158
+ discount_per: (_k = payload._extend) == null ? void 0 : _k.discount_per
159
+ })
160
+ ) : payload.discount_list || [];
127
161
  const metadata = {
128
162
  unique: payload.unique,
129
163
  session: payload.session,
@@ -138,7 +172,10 @@ function transformBaseProductToOrderProduct(params) {
138
172
  source_product_price: sourceProductPrice,
139
173
  main_product_selling_price: sourceProductPrice,
140
174
  main_product_original_price: sourceProductPrice,
141
- ...hasPriceOverride ? { price_override: String(payload.price_override) } : {},
175
+ ...hasPriceOverride ? {
176
+ price_override: String(payload.price_override),
177
+ is_manual_discount: 1
178
+ } : {},
142
179
  ...payload.bundle_edit !== void 0 ? { bundle_edit: payload.bundle_edit } : {}
143
180
  };
144
181
  if (uniqueIdentificationNumber) {
@@ -148,12 +185,13 @@ function transformBaseProductToOrderProduct(params) {
148
185
  product_id: productId,
149
186
  product_variant_id: productVariantId,
150
187
  unique_identification_number: uniqueIdentificationNumber ? String(uniqueIdentificationNumber) : void 0,
151
- num: toSafePositiveInt(payload.quantity ?? payload.num, 1),
188
+ num: resolvedQuantity,
152
189
  product_option_item: productOptionItem,
153
190
  product_bundle: productBundle,
191
+ discount_list: manualDiscountList,
154
192
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
155
193
  selling_price: lineCompositeTotal,
156
- original_price: lineCompositeTotal,
194
+ original_price: lineOriginalPrice,
157
195
  tax_fee: toPriceString(
158
196
  payload.tax_fee ?? (matchedVariant == null ? void 0 : matchedVariant.tax_fee) ?? (origin == null ? void 0 : origin.tax_fee) ?? (sourceProduct == null ? void 0 : sourceProduct.tax_fee),
159
197
  "0.00"
@@ -38,6 +38,7 @@ __export(utils_exports, {
38
38
  module.exports = __toCommonJS(utils_exports);
39
39
  var import_decimal = __toESM(require("decimal.js"));
40
40
  var import_utils = require("../../modules/Order/utils");
41
+ var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
41
42
  function createEmptySummary() {
42
43
  return {
43
44
  product_quantity: 0,
@@ -203,9 +204,16 @@ function normalizeOrderProduct(product) {
203
204
  useOriginalBundle: true
204
205
  });
205
206
  const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
206
- { num: product.num, metadata },
207
+ { num: product.num, metadata, lineOriginalPrice: product.original_price },
207
208
  composedOriginalPrice
208
209
  );
210
+ const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
211
+ discountList: product.discount_list,
212
+ metadata,
213
+ originalPrice: finalOriginalPrice,
214
+ sellingPrice: composedSellingPrice,
215
+ quantity: getSafeProductNum(product.num)
216
+ });
209
217
  return {
210
218
  order_detail_id: product.order_detail_id || null,
211
219
  product_id: product.product_id,
@@ -216,7 +224,7 @@ function normalizeOrderProduct(product) {
216
224
  original_price: finalOriginalPrice,
217
225
  tax_fee: product.tax_fee || "0.00",
218
226
  is_charge_tax: product.is_charge_tax ?? 0,
219
- discount_list: product.discount_list || [],
227
+ discount_list: discountList,
220
228
  product_bundle: normalizedBundle,
221
229
  metadata,
222
230
  note: product.note != null ? String(product.note) : ""
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 1 | 2 | 6 | 3 | 5 | 4;
314
+ weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -260,7 +260,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
260
260
  * 获取当前的客户搜索条件
261
261
  * @returns 当前搜索条件
262
262
  */
263
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
263
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
264
264
  /**
265
265
  * 获取客户列表状态(包含滚动加载相关状态)
266
266
  * @returns 客户状态
@@ -176,7 +176,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
176
176
  if (normalizedLocalCustomer && this.hasUsableCustomerDetails(normalizedLocalCustomer)) {
177
177
  return normalizedLocalCustomer;
178
178
  }
179
- const result = await this.store.customer.getCustomerList({
179
+ const result = await this.store.customer.queryCustomerList({
180
180
  ids: [customerId],
181
181
  skip: 1,
182
182
  num: 1
@@ -290,7 +290,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
290
290
  */
291
291
  async loadProducts(params = {}, options) {
292
292
  const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
293
- const bookingDate = schedule_date || (schedule_datetime ? String(schedule_datetime).slice(0, 10) : "");
293
+ const bookingDate = schedule_datetime || schedule_date || "";
294
294
  if (bookingDate) {
295
295
  this.setBookingDate(bookingDate);
296
296
  }
@@ -184,7 +184,7 @@ function buildRequiresDetailPayload(item, ctx) {
184
184
  number: Boolean(item == null ? void 0 : item.open_sold_weight)
185
185
  },
186
186
  isOnlySession,
187
- isEject,
187
+ isEject: isEject ? 1 : 0,
188
188
  customerId: ctx == null ? void 0 : ctx.customerId,
189
189
  date: formatBookingDateForUI(ctx == null ? void 0 : ctx.date),
190
190
  productData: item
@@ -298,6 +298,8 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
298
298
  origin_total: extend == null ? void 0 : extend.origin_total,
299
299
  price_override: extend == null ? void 0 : extend.priceOverride,
300
300
  bundle_edit: extend == null ? void 0 : extend.bundle_edit,
301
+ discount_reason: extend == null ? void 0 : extend.discount_reason,
302
+ discount_list: cacheItem == null ? void 0 : cacheItem.discount_list,
301
303
  _extend: extend
302
304
  };
303
305
  }
@@ -63,6 +63,7 @@ module.exports = __toCommonJS(utils_exports);
63
63
  var import_dayjs = __toESM(require("dayjs"));
64
64
  var import_decimal = __toESM(require("decimal.js"));
65
65
  var import_utils = require("../../modules/Order/utils");
66
+ var import_manualProductDiscount = require("../../modules/Order/utils/manualProductDiscount");
66
67
  function createEmptySummary() {
67
68
  return {
68
69
  product_quantity: 0,
@@ -507,9 +508,16 @@ function normalizeOrderProduct(product) {
507
508
  useOriginalBundle: true
508
509
  });
509
510
  const finalOriginalPrice = (0, import_utils.resolveManualOverrideLineOriginalPrice)(
510
- { num: product.num, metadata },
511
+ { num: product.num, metadata, lineOriginalPrice: product.original_price },
511
512
  composedOriginalPrice
512
513
  );
514
+ const discountList = (0, import_manualProductDiscount.ensureManualProductDiscountList)({
515
+ discountList: product.discount_list,
516
+ metadata,
517
+ originalPrice: finalOriginalPrice,
518
+ sellingPrice: composedSellingPrice,
519
+ quantity: getSafeProductNum(product.num)
520
+ });
513
521
  return {
514
522
  order_detail_id: product.order_detail_id || null,
515
523
  product_id: product.product_id,
@@ -520,7 +528,7 @@ function normalizeOrderProduct(product) {
520
528
  original_price: finalOriginalPrice,
521
529
  tax_fee: product.tax_fee || "0.00",
522
530
  is_charge_tax: product.is_charge_tax ?? 0,
523
- discount_list: product.discount_list || [],
531
+ discount_list: discountList,
524
532
  product_bundle: normalizedBundle,
525
533
  metadata,
526
534
  note: product.note != null ? String(product.note) : ""
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.168",
4
+ "version": "2.2.169",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",