@pisell/pisellos 2.2.272 → 2.2.273

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.
@@ -190,7 +190,7 @@ function synthesizeProductResourceFromBooking(booking) {
190
190
  * 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
191
191
  */
192
192
  export function buildCacheItemFromOrderLine(input) {
193
- var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref12, _booking$id;
193
+ var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref10, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref11, _extension_type, _booking$product2, _booking$product3, _price, _product$product_sku, _product$order_detail, _ref12, _booking$id;
194
194
  var product = input.product,
195
195
  booking = input.booking,
196
196
  sourceProduct = input.sourceProduct;
@@ -257,7 +257,7 @@ export function buildCacheItemFromOrderLine(input) {
257
257
  if (Array.isArray(booking.relation_forms)) {
258
258
  extend.relation_forms = booking.relation_forms;
259
259
  }
260
- var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
260
+ var base = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
261
261
  id: resolvedId,
262
262
  product_id: resolvedId,
263
263
  extension_type: (_ref11 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref11 !== void 0 ? _ref11 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
@@ -265,7 +265,9 @@ export function buildCacheItemFromOrderLine(input) {
265
265
  price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
266
266
  selling_price: product.selling_price,
267
267
  original_price: product.original_price
268
- }, productOptionString ? {
268
+ }, Number(((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1 ? {
269
+ product_sku: JSON.parse(JSON.stringify(product.product_sku))
270
+ } : {}), productOptionString ? {
269
271
  product_option_string: productOptionString
270
272
  } : {}), {}, {
271
273
  _extend: extend,
@@ -75,7 +75,7 @@ function mapOrderBundleToOtherBundle(bundle) {
75
75
  });
76
76
  }
77
77
  export function buildNormalProductCacheItemFromOrderLine(input) {
78
- var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _ref7, _cover, _price3, _product$order_detail;
78
+ var _product$product_id, _product$selling_pric2, _product$original_pri, _product$metadata, _product$metadata2, _product$product_vari, _originExtend$other, _product$num, _product$product_vari2, _product$num2, _title, _product$note, _originExtend$price, _originExtend$total, _originExtend$origin_, _product$metadata3, _ref6, _title2, _ref7, _cover, _price3, _product$order_detail, _product$product_sku;
79
79
  var product = input.product,
80
80
  sourceProduct = input.sourceProduct;
81
81
  var resolvedId = (_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.id;
@@ -127,7 +127,7 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
127
127
  extend.skuValue = JSON.parse(JSON.stringify(originExtend.skuValue || originExtend._skuValue));
128
128
  extend._skuValue = JSON.parse(JSON.stringify(extend.skuValue));
129
129
  }
130
- return _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
130
+ return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
131
131
  id: resolvedId,
132
132
  product_id: resolvedId,
133
133
  _id: uid,
@@ -141,7 +141,10 @@ export function buildNormalProductCacheItemFromOrderLine(input) {
141
141
  } : {}), {}, {
142
142
  note: product.note,
143
143
  order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
144
- discount_list: discountList,
144
+ discount_list: discountList
145
+ }, Number(((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.open_sold_weight) || 0) === 1 ? {
146
+ product_sku: JSON.parse(JSON.stringify(product.product_sku))
147
+ } : {}), {}, {
145
148
  new: 0,
146
149
  autoClose: true,
147
150
  _extend: extend
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
485
485
  generateIdempotencyToken(): string;
486
486
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
487
487
  createOrder(params: CommitOrderParams['query']): {
488
- type: "appointment_booking" | "virtual";
488
+ type: "virtual" | "appointment_booking";
489
489
  platform: string;
490
490
  sales_channel: string;
491
491
  order_sales_channel: string;
@@ -4858,7 +4858,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4858
4858
  key: "saveTempOrderAsDraft",
4859
4859
  value: function () {
4860
4860
  var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
4861
- var _params$cacheId2, _this$otherParams6, _ref74, _params$businessCode2, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4861
+ var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
4862
4862
  var tempOrder, latestSummary, payload;
4863
4863
  return _regeneratorRuntime().wrap(function _callee31$(_context34) {
4864
4864
  while (1) switch (_context34.prev = _context34.next) {
@@ -4890,7 +4890,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4890
4890
  tempOrder: tempOrder,
4891
4891
  cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
4892
4892
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
4893
- businessCode: (_ref74 = (_params$businessCode2 = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
4893
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
4894
4894
  channel: params === null || params === void 0 ? void 0 : params.channel,
4895
4895
  type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
4896
4896
  summary: latestSummary,
@@ -4971,7 +4971,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
4971
4971
  key: "runSubmitTempOrder",
4972
4972
  value: function () {
4973
4973
  var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
4974
- var _params$cacheId3, _this$otherParams10, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4974
+ var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
4975
4975
  var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
4976
4976
  return _regeneratorRuntime().wrap(function _callee34$(_context37) {
4977
4977
  while (1) switch (_context37.prev = _context37.next) {
@@ -5033,7 +5033,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
5033
5033
  tempOrder: tempOrder,
5034
5034
  cacheId: effectiveCacheId,
5035
5035
  platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
5036
- businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5036
+ businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
5037
5037
  channel: params === null || params === void 0 ? void 0 : params.channel,
5038
5038
  type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
5039
5039
  summary: latestSummary,
@@ -6065,7 +6065,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6065
6065
  _step24;
6066
6066
  try {
6067
6067
  for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
6068
- var _product$metadata11, _ref77, _ref78, _existed$origin, _rawProduct$metadata;
6068
+ var _product$metadata11, _ref76, _ref77, _existed$origin, _rawProduct$metadata;
6069
6069
  var _step24$value = _slicedToArray(_step24.value, 2),
6070
6070
  index = _step24$value[0],
6071
6071
  product = _step24$value[1];
@@ -6073,7 +6073,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6073
6073
  if (!uid) continue;
6074
6074
  var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
6075
6075
  var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
6076
- var origin = (_ref77 = (_ref78 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref78 !== void 0 ? _ref78 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref77 !== void 0 ? _ref77 : rawProduct;
6076
+ var origin = (_ref76 = (_ref77 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref77 !== void 0 ? _ref77 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref76 !== void 0 ? _ref76 : rawProduct;
6077
6077
  var originSnapshot = cloneDeep(origin);
6078
6078
  var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
6079
6079
  if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
@@ -6202,10 +6202,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6202
6202
  }, {
6203
6203
  key: "normalizeHydratedProductOptionItem",
6204
6204
  value: function normalizeHydratedProductOptionItem(optionItem) {
6205
- var _ref79, _optionItem$num, _ref80, _optionItem$add_price;
6206
- var rawNum = (_ref79 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref79 !== void 0 ? _ref79 : 1;
6205
+ var _ref78, _optionItem$num, _ref79, _optionItem$add_price;
6206
+ var rawNum = (_ref78 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref78 !== void 0 ? _ref78 : 1;
6207
6207
  var parsedNum = Number(rawNum);
6208
- var rawPrice = (_ref80 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref80 !== void 0 ? _ref80 : 0;
6208
+ var rawPrice = (_ref79 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref79 !== void 0 ? _ref79 : 0;
6209
6209
  var parsedPrice = Number(rawPrice);
6210
6210
  var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
6211
6211
  option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
@@ -6346,10 +6346,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
6346
6346
  _step29;
6347
6347
  try {
6348
6348
  for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
6349
- var _ref81, _bundle$num3;
6349
+ var _ref80, _bundle$num3;
6350
6350
  var bundle = _step29.value;
6351
6351
  var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
6352
- var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref81 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref81 !== void 0 ? _ref81 : 1) || 1).toNumber();
6352
+ var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref80 = (_bundle$num3 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num3 !== void 0 ? _bundle$num3 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref80 !== void 0 ? _ref80 : 1) || 1).toNumber();
6353
6353
  var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
6354
6354
  _step30;
6355
6355
  try {
@@ -167,6 +167,11 @@ export declare class OrderModule extends BaseModule implements Module {
167
167
  private syncOrdersMap;
168
168
  private getOrderMapKey;
169
169
  private isBlankIdentityValue;
170
+ /**
171
+ * `/sales/draft` 的旧调用方可能把未设置的 business_code 传成空串。
172
+ * 对同一真实订单,空值不能覆盖已有的分类,否则 booking 查询会把该订单从 Party 列表过滤掉。
173
+ */
174
+ private preserveExistingBusinessCodeForDraft;
170
175
  private getOrderIdentityEntries;
171
176
  private getOrderIdentityKeys;
172
177
  private getOrderDateKey;
@@ -1572,7 +1572,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1572
1572
  value: (function () {
1573
1573
  var _upsertLocalDraftOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(draftOrders) {
1574
1574
  var _this10 = this;
1575
- var draftMap, memoryDraftMap, _iterator8, _step8, order, draftOrder, storageKey, memoryDraftOrder, patchedOrders, mergeActions, updatedList, identityKeyToIndex, index, _iterator9, _step9, key, _iterator10, _step10, _step10$value, _storageKey2, _draftOrder, matchIndex, mergedOrder, nextOrder, insertIndex, previousList, removedLegacyMemoryDraft;
1575
+ var draftMap, memoryDraftMap, _iterator8, _step8, order, draftOrder, storageKey, memoryDraftOrder, mergeActions, updatedList, identityKeyToIndex, index, _iterator9, _step9, key, _iterator10, _step10, _step10$value, _storageKey2, _draftOrder, matchIndex, existingOrder, reconciledDraftOrder, mergedOrder, nextOrder, insertIndex, patchedOrders, previousList, removedLegacyMemoryDraft;
1576
1576
  return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1577
1577
  while (1) switch (_context13.prev = _context13.next) {
1578
1578
  case 0:
@@ -1639,7 +1639,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1639
1639
  memoryDraftCount: memoryDraftMap.size,
1640
1640
  sqliteOnlyDraftCount: draftMap.size - memoryDraftMap.size
1641
1641
  });
1642
- patchedOrders = _toConsumableArray(draftMap.values());
1643
1642
  mergeActions = {};
1644
1643
  updatedList = this.store.list.filter(function (order) {
1645
1644
  return _this10.shouldKeepOrderInMemory(order);
@@ -1659,66 +1658,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1659
1658
  }
1660
1659
  }
1661
1660
  _iterator10 = _createForOfIteratorHelper(memoryDraftMap.entries());
1662
- _context13.prev = 37;
1661
+ _context13.prev = 36;
1663
1662
  _iterator10.s();
1664
- case 39:
1663
+ case 38:
1665
1664
  if ((_step10 = _iterator10.n()).done) {
1666
- _context13.next = 55;
1665
+ _context13.next = 57;
1667
1666
  break;
1668
1667
  }
1669
1668
  _step10$value = _slicedToArray(_step10.value, 2), _storageKey2 = _step10$value[0], _draftOrder = _step10$value[1];
1670
1669
  matchIndex = this.lookupOrderIndexByIdentityKeys(identityKeyToIndex, this.getOrderIdentityMatchKeys(_draftOrder));
1671
1670
  if (!(matchIndex >= 0)) {
1672
- _context13.next = 49;
1671
+ _context13.next = 51;
1673
1672
  break;
1674
1673
  }
1675
- mergedOrder = this.mergeOrderRecords(updatedList[matchIndex], _draftOrder);
1674
+ existingOrder = updatedList[matchIndex];
1675
+ reconciledDraftOrder = this.preserveExistingBusinessCodeForDraft(existingOrder, _draftOrder);
1676
+ mergedOrder = this.mergeOrderRecords(existingOrder, reconciledDraftOrder);
1676
1677
  nextOrder = _objectSpread(_objectSpread({}, mergedOrder), {}, {
1677
1678
  need_sync: 0,
1678
1679
  is_draft_order: 1
1679
1680
  });
1680
1681
  updatedList[matchIndex] = nextOrder;
1682
+ // SQLite 必须与内存中的草稿保持同一份 business_code,避免下次 hydrate 再次丢失分类。
1683
+ draftMap.set(_storageKey2, reconciledDraftOrder);
1681
1684
  this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
1682
1685
  mergeActions[_storageKey2] = 'update';
1683
- return _context13.abrupt("continue", 53);
1684
- case 49:
1686
+ return _context13.abrupt("continue", 55);
1687
+ case 51:
1685
1688
  insertIndex = updatedList.length;
1686
1689
  updatedList.push(_draftOrder);
1687
1690
  this.registerOrderIdentityKeys(identityKeyToIndex, _draftOrder, insertIndex);
1688
1691
  mergeActions[_storageKey2] = 'insert';
1689
- case 53:
1690
- _context13.next = 39;
1691
- break;
1692
1692
  case 55:
1693
- _context13.next = 60;
1693
+ _context13.next = 38;
1694
1694
  break;
1695
1695
  case 57:
1696
- _context13.prev = 57;
1697
- _context13.t1 = _context13["catch"](37);
1696
+ _context13.next = 62;
1697
+ break;
1698
+ case 59:
1699
+ _context13.prev = 59;
1700
+ _context13.t1 = _context13["catch"](36);
1698
1701
  _iterator10.e(_context13.t1);
1699
- case 60:
1700
- _context13.prev = 60;
1702
+ case 62:
1703
+ _context13.prev = 62;
1701
1704
  _iterator10.f();
1702
- return _context13.finish(60);
1703
- case 63:
1705
+ return _context13.finish(62);
1706
+ case 65:
1707
+ patchedOrders = _toConsumableArray(draftMap.values());
1704
1708
  previousList = this.store.list;
1705
1709
  this.store.list = this.runOrderStoreSelfCheck(updatedList, 'upsertLocalDraftOrders.store');
1706
1710
  this.syncOrdersMap();
1707
- _context13.prev = 66;
1708
- _context13.next = 69;
1711
+ _context13.prev = 69;
1712
+ _context13.next = 72;
1709
1713
  return this.patchOrdersInSQLite(patchedOrders, 'upsertLocalDraftOrders', mergeActions, {
1710
1714
  throwOnError: true
1711
1715
  });
1712
- case 69:
1713
- _context13.next = 76;
1716
+ case 72:
1717
+ _context13.next = 79;
1714
1718
  break;
1715
- case 71:
1716
- _context13.prev = 71;
1717
- _context13.t2 = _context13["catch"](66);
1719
+ case 74:
1720
+ _context13.prev = 74;
1721
+ _context13.t2 = _context13["catch"](69);
1718
1722
  this.store.list = previousList;
1719
1723
  this.syncOrdersMap();
1720
1724
  throw _context13.t2;
1721
- case 76:
1725
+ case 79:
1722
1726
  this.logInfo('upsertLocalDraftOrders-结束', {
1723
1727
  count: patchedOrders.length,
1724
1728
  storeOrderCountAfter: this.store.list.length
@@ -1727,18 +1731,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1727
1731
  return !_this10.shouldKeepOrderInMemory(order);
1728
1732
  });
1729
1733
  if (!(memoryDraftMap.size > 0 || removedLegacyMemoryDraft)) {
1730
- _context13.next = 81;
1734
+ _context13.next = 84;
1731
1735
  break;
1732
1736
  }
1733
- _context13.next = 81;
1737
+ _context13.next = 84;
1734
1738
  return this.emitOrdersChanged(patchedOrders.filter(function (order) {
1735
1739
  return _this10.shouldKeepOrderInMemory(order);
1736
1740
  }), 'upsertLocalDraftOrders');
1737
- case 81:
1741
+ case 84:
1738
1742
  case "end":
1739
1743
  return _context13.stop();
1740
1744
  }
1741
- }, _callee13, this, [[6, 21, 24, 27], [37, 57, 60, 63], [66, 71]]);
1745
+ }, _callee13, this, [[6, 21, 24, 27], [36, 59, 62, 65], [69, 74]]);
1742
1746
  }));
1743
1747
  function upsertLocalDraftOrders(_x10) {
1744
1748
  return _upsertLocalDraftOrders.apply(this, arguments);
@@ -1853,6 +1857,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
1853
1857
  value: function isBlankIdentityValue(value) {
1854
1858
  return value === undefined || value === null || value === '';
1855
1859
  }
1860
+
1861
+ /**
1862
+ * `/sales/draft` 的旧调用方可能把未设置的 business_code 传成空串。
1863
+ * 对同一真实订单,空值不能覆盖已有的分类,否则 booking 查询会把该订单从 Party 列表过滤掉。
1864
+ */
1865
+ }, {
1866
+ key: "preserveExistingBusinessCodeForDraft",
1867
+ value: function preserveExistingBusinessCodeForDraft(existingOrder, draftOrder) {
1868
+ var existingBusinessCode = existingOrder.business_code;
1869
+ var draftBusinessCode = draftOrder.business_code;
1870
+ var hasExistingBusinessCode = typeof existingBusinessCode === 'string' && existingBusinessCode.trim() !== '';
1871
+ var hasDraftBusinessCode = typeof draftBusinessCode === 'string' && draftBusinessCode.trim() !== '';
1872
+ if (!hasExistingBusinessCode || hasDraftBusinessCode) return draftOrder;
1873
+ return _objectSpread(_objectSpread({}, draftOrder), {}, {
1874
+ business_code: existingBusinessCode
1875
+ });
1876
+ }
1856
1877
  }, {
1857
1878
  key: "getOrderIdentityEntries",
1858
1879
  value: function getOrderIdentityEntries(order) {
@@ -2743,7 +2743,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2743
2743
  key: "saveSalesOrderDraft",
2744
2744
  value: function () {
2745
2745
  var _saveSalesOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
2746
- var _params$platform, _this$otherParams10, _ref22, _params$businessCode, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2746
+ var _params$platform, _this$otherParams10, _this$otherParams11, _this$otherParams12, _params$channel, _params$type, _this$otherParams13;
2747
2747
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2748
2748
  while (1) switch (_context28.prev = _context28.next) {
2749
2749
  case 0:
@@ -2756,7 +2756,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2756
2756
  return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
2757
2757
  cacheId: this.cacheId,
2758
2758
  platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
2759
- businessCode: (_ref22 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
2759
+ businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code),
2760
2760
  channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
2761
2761
  type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
2762
2762
  }, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
@@ -2902,7 +2902,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2902
2902
  key: "syncPaymentsToOrder",
2903
2903
  value: function () {
2904
2904
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2905
- var _ref23, _params$businessCode2, _this$otherParams22, _this$otherParams23, _params$channel2;
2905
+ var _ref22, _params$businessCode, _this$otherParams22, _this$otherParams23, _params$channel2;
2906
2906
  var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
2907
2907
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2908
2908
  while (1) switch (_context31.prev = _context31.next) {
@@ -2913,7 +2913,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2913
2913
  }
2914
2914
  throw new Error('order 模块未初始化');
2915
2915
  case 2:
2916
- businessCode = (_ref23 = (_params$businessCode2 = params.businessCode) !== null && _params$businessCode2 !== void 0 ? _params$businessCode2 : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref23 !== void 0 ? _ref23 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
2916
+ businessCode = (_ref22 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.business_code;
2917
2917
  channel = (_params$channel2 = params.channel) !== null && _params$channel2 !== void 0 ? _params$channel2 : this.getSubmitOrderSalesChannel();
2918
2918
  syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
2919
2919
  businessCode: businessCode
@@ -3173,7 +3173,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3173
3173
  var _this$otherParams24,
3174
3174
  _paymentRecord$paymen,
3175
3175
  _paymentRecord$create,
3176
- _ref24,
3176
+ _ref23,
3177
3177
  _paymentRecord$origin,
3178
3178
  _this14 = this;
3179
3179
  if (!this.store.order) throw new Error('order 模块未初始化');
@@ -3195,7 +3195,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3195
3195
  var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
3196
3196
  var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
3197
3197
  var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
3198
- var calculatedServiceFee = serviceCharge ? new Decimal((_ref24 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref24 !== void 0 ? _ref24 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3198
+ var calculatedServiceFee = serviceCharge ? new Decimal((_ref23 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref23 !== void 0 ? _ref23 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
3199
3199
  var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, normalizedPaymentRecord), calculatedServiceFee !== undefined ? {
3200
3200
  service_fee: calculatedServiceFee
3201
3201
  } : {}), {}, {
@@ -3471,7 +3471,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3471
3471
  key: "initWalletData",
3472
3472
  value: function () {
3473
3473
  var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
3474
- var _params$order_wait_pa, _ref25, _tempOrder$is_price_i;
3474
+ var _params$order_wait_pa, _ref24, _tempOrder$is_price_i;
3475
3475
  var snapshot, tempOrder, amount, walletBusinessData, result;
3476
3476
  return _regeneratorRuntime().wrap(function _callee36$(_context36) {
3477
3477
  while (1) switch (_context36.prev = _context36.next) {
@@ -3514,7 +3514,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3514
3514
  },
3515
3515
  products: this.getWalletProductList(),
3516
3516
  order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
3517
- is_price_include_tax: (_ref25 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref25 !== void 0 ? _ref25 : 1
3517
+ is_price_include_tax: (_ref24 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref24 !== void 0 ? _ref24 : 1
3518
3518
  }, snapshot.identity.orderId ? {
3519
3519
  payment_order_id: String(snapshot.identity.orderId)
3520
3520
  } : {});
@@ -3645,7 +3645,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3645
3645
  key: "sendCustomerPayLink",
3646
3646
  value: (function () {
3647
3647
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
3648
- var orderIds, _ref26, _ref27, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3648
+ var orderIds, _ref25, _ref26, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
3649
3649
  return _regeneratorRuntime().wrap(function _callee38$(_context38) {
3650
3650
  while (1) switch (_context38.prev = _context38.next) {
3651
3651
  case 0:
@@ -3666,7 +3666,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3666
3666
  });
3667
3667
  case 6:
3668
3668
  submitResult = _context38.sent;
3669
- orderId = (_ref26 = (_ref27 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref27 !== void 0 ? _ref27 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3669
+ orderId = (_ref25 = (_ref26 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref26 !== void 0 ? _ref26 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref25 !== void 0 ? _ref25 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
3670
3670
  if (orderId) {
3671
3671
  _context38.next = 10;
3672
3672
  break;
@@ -3838,12 +3838,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3838
3838
  });
3839
3839
  _context41.next = 9;
3840
3840
  return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
3841
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref28) {
3842
- var _ref30, groupKey, group, productsById;
3841
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(_ref27) {
3842
+ var _ref29, groupKey, group, productsById;
3843
3843
  return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3844
3844
  while (1) switch (_context40.prev = _context40.next) {
3845
3845
  case 0:
3846
- _ref30 = _slicedToArray(_ref28, 2), groupKey = _ref30[0], group = _ref30[1];
3846
+ _ref29 = _slicedToArray(_ref27, 2), groupKey = _ref29[0], group = _ref29[1];
3847
3847
  _context40.next = 3;
3848
3848
  return _this16.loadProductsForPriceQuery({
3849
3849
  ids: Array.from(group.ids),
@@ -3861,7 +3861,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
3861
3861
  }, _callee40);
3862
3862
  }));
3863
3863
  return function (_x35) {
3864
- return _ref29.apply(this, arguments);
3864
+ return _ref28.apply(this, arguments);
3865
3865
  };
3866
3866
  }()));
3867
3867
  case 9:
@@ -4290,14 +4290,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
4290
4290
  value: function () {
4291
4291
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
4292
4292
  var _this$otherParams26;
4293
- var _ref31,
4294
- _ref31$cover,
4293
+ var _ref30,
4294
+ _ref30$cover,
4295
4295
  cover,
4296
4296
  _args51 = arguments;
4297
4297
  return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4298
4298
  while (1) switch (_context51.prev = _context51.next) {
4299
4299
  case 0:
4300
- _ref31 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref31$cover = _ref31.cover, cover = _ref31$cover === void 0 ? false : _ref31$cover;
4300
+ _ref30 = _args51.length > 1 && _args51[1] !== undefined ? _args51[1] : {}, _ref30$cover = _ref30.cover, cover = _ref30$cover === void 0 ? false : _ref30$cover;
4301
4301
  if (cover) {
4302
4302
  this.otherParams = _objectSpread({}, params);
4303
4303
  } else {
@@ -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 | 2 | 1 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import dayjs from 'dayjs';
8
8
  import { cacheItemToBookingInput, derivePresetStartTimeFromDate, getProductExtend, getIsAutoClose, isSessionProduct, isBookingProduct, applySessionTimesToExtend, hasActualResourceSelection, productNeedsResourceExtend } from "../../../modules/BookingContext";
9
9
  import { transformBaseProductToOrderProduct } from "../../BaseSales/utils/transformBaseProductToOrderProduct";
10
+ import { buildProductSkuFromCacheItem } from "./weighingProductSku";
10
11
 
11
12
  /**
12
13
  * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
@@ -322,11 +323,16 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
322
323
  var quantity = (ctx === null || ctx === void 0 ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : (_cacheItem$_extend$qu = cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.quantity) !== null && _cacheItem$_extend$qu !== void 0 ? _cacheItem$_extend$qu : 1;
323
324
  var resolvedPid = (_cacheItem$product_id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id) !== null && _cacheItem$product_id !== void 0 ? _cacheItem$product_id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id;
324
325
  var extend = (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem._extend) || {};
326
+ var productSku = buildProductSkuFromCacheItem(cacheItem);
325
327
  return {
326
328
  id: (_cacheItem$id = cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.id) !== null && _cacheItem$id !== void 0 ? _cacheItem$id : cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_id,
327
329
  product_id: resolvedPid,
328
330
  variant_id: (_ref5 = (_other$product_varian = other === null || other === void 0 ? void 0 : other.product_variant_id) !== null && _other$product_varian !== void 0 ? _other$product_varian : other === null || other === void 0 ? void 0 : other.variant_id) !== null && _ref5 !== void 0 ? _ref5 : 0,
329
331
  quantity: quantity,
332
+ // 规格弹窗本次选择是 option 权威源,避免目录/旧订单里的空 option 覆盖它。
333
+ product_sku: productSku ? _objectSpread(_objectSpread({}, productSku), {}, {
334
+ option: (other === null || other === void 0 ? void 0 : other.option) || []
335
+ }) : undefined,
330
336
  option: (other === null || other === void 0 ? void 0 : other.option) || [],
331
337
  bundle: (other === null || other === void 0 ? void 0 : other.bundle) || (extend === null || extend === void 0 || (_extend$skuValue = extend.skuValue) === null || _extend$skuValue === void 0 ? void 0 : _extend$skuValue.bundle) || (extend === null || extend === void 0 || (_extend$_skuValue = extend._skuValue) === null || _extend$_skuValue === void 0 ? void 0 : _extend$_skuValue.bundle) || [],
332
338
  unique: other === null || other === void 0 ? void 0 : other.unique,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
3
+ * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
4
+ */
5
+ export declare function buildProductSkuFromCacheItem(cacheItem: Record<string, any> | null | undefined): Record<string, any> | undefined;
@@ -0,0 +1,45 @@
1
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
5
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
6
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7
+ var WEIGHT_UNIT_MAP = {
8
+ KILOGRAMS: 'kg',
9
+ GRAMS: 'g',
10
+ POUNDS: 'lb',
11
+ OUNCES: 'oz'
12
+ };
13
+ function isRecord(value) {
14
+ return Boolean(value) && _typeof(value) === 'object' && !Array.isArray(value);
15
+ }
16
+
17
+ /**
18
+ * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
19
+ * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
20
+ */
21
+ export function buildProductSkuFromCacheItem(cacheItem) {
22
+ var _cacheItem$_extend, _cacheItem$_extend2, _weighing$unit_weight, _weighing$tare$label, _weighing$tare, _weighing$tare$value, _weighing$tare2, _weighing$weight, _weighing$net_weight;
23
+ var currentSku = isRecord(cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.product_sku) ? cacheItem.product_sku : undefined;
24
+ var weighing = isRecord(cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.weighing) ? cacheItem === null || cacheItem === void 0 || (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.weighing : undefined;
25
+ var hasRuntimeWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1 && ((currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.net_weight) !== undefined || (currentSku === null || currentSku === void 0 ? void 0 : currentSku.weight_source) !== undefined);
26
+ var isWeighingSku = Number((currentSku === null || currentSku === void 0 ? void 0 : currentSku.open_sold_weight) || 0) === 1;
27
+
28
+ // 普通商品维持旧转换行为,不把目录侧完整 SKU 引入订单行。
29
+ if (!isWeighingSku && !weighing) return undefined;
30
+ // 新版 SkuDetailModal 已直接生成 product_sku;_extend.weighing 只作为旧调用方回退。
31
+ if (hasRuntimeWeighingSku) return _objectSpread({}, currentSku);
32
+ if (!weighing) return currentSku ? _objectSpread({}, currentSku) : undefined;
33
+ return _objectSpread(_objectSpread({}, currentSku || {}), {}, {
34
+ open_sold_weight: 1,
35
+ unit_data_snapshot: weighing.scalePriceProduct,
36
+ unit: WEIGHT_UNIT_MAP[String(weighing.unit)] || weighing.unit,
37
+ unit_weight: (_weighing$unit_weight = weighing.unit_weight) !== null && _weighing$unit_weight !== void 0 ? _weighing$unit_weight : '1.000',
38
+ unit_price: weighing.unit_price,
39
+ weight_source: weighing.mode,
40
+ tare_name: (_weighing$tare$label = (_weighing$tare = weighing.tare) === null || _weighing$tare === void 0 ? void 0 : _weighing$tare.label) !== null && _weighing$tare$label !== void 0 ? _weighing$tare$label : '',
41
+ tare_weight: (_weighing$tare$value = (_weighing$tare2 = weighing.tare) === null || _weighing$tare2 === void 0 ? void 0 : _weighing$tare2.value) !== null && _weighing$tare$value !== void 0 ? _weighing$tare$value : 0,
42
+ weight: (_weighing$weight = weighing.weight) !== null && _weighing$weight !== void 0 ? _weighing$weight : 0,
43
+ net_weight: (_weighing$net_weight = weighing.net_weight) !== null && _weighing$net_weight !== void 0 ? _weighing$net_weight : 0
44
+ });
45
+ }
@@ -0,0 +1,51 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/model/strategy/adapter/promotion/index.ts
30
+ var promotion_exports = {};
31
+ __export(promotion_exports, {
32
+ BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
+ ITEM_REWARD_STRATEGY: () => import_examples.ITEM_REWARD_STRATEGY,
34
+ PromotionAdapter: () => import_adapter.PromotionAdapter,
35
+ PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
36
+ X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
37
+ default: () => import_adapter2.default
38
+ });
39
+ module.exports = __toCommonJS(promotion_exports);
40
+ var import_evaluator = require("./evaluator");
41
+ var import_adapter = require("./adapter");
42
+ var import_adapter2 = __toESM(require("./adapter"));
43
+ var import_examples = require("./examples");
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ BUY_X_GET_Y_FREE_STRATEGY,
47
+ ITEM_REWARD_STRATEGY,
48
+ PromotionAdapter,
49
+ PromotionEvaluator,
50
+ X_ITEMS_FOR_Y_PRICE_STRATEGY
51
+ });
@@ -184,7 +184,7 @@ function synthesizeProductResourceFromBooking(booking) {
184
184
  };
185
185
  }
186
186
  function buildCacheItemFromOrderLine(input) {
187
- var _a, _b, _c, _d, _e, _f;
187
+ var _a, _b, _c, _d, _e, _f, _g;
188
188
  const { product, booking, sourceProduct } = input;
189
189
  const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
190
190
  const selling = Number(product.selling_price ?? 0);
@@ -259,6 +259,7 @@ function buildCacheItemFromOrderLine(input) {
259
259
  price: (sourceProduct == null ? void 0 : sourceProduct.price) ?? selling,
260
260
  selling_price: product.selling_price,
261
261
  original_price: product.original_price,
262
+ ...Number(((_g = product.product_sku) == null ? void 0 : _g.open_sold_weight) || 0) === 1 ? { product_sku: JSON.parse(JSON.stringify(product.product_sku)) } : {},
262
263
  ...productOptionString ? { product_option_string: productOptionString } : {},
263
264
  _extend: extend,
264
265
  new: 0,
@@ -78,7 +78,7 @@ function mapOrderBundleToOtherBundle(bundle) {
78
78
  });
79
79
  }
80
80
  function buildNormalProductCacheItemFromOrderLine(input) {
81
- var _a, _b, _c, _d, _e;
81
+ var _a, _b, _c, _d, _e, _f;
82
82
  const { product, sourceProduct } = input;
83
83
  const resolvedId = product.product_id ?? (sourceProduct == null ? void 0 : sourceProduct.id);
84
84
  const sourcePrice = resolveSourceProductPrice(product, sourceProduct);
@@ -144,6 +144,7 @@ function buildNormalProductCacheItemFromOrderLine(input) {
144
144
  note: product.note,
145
145
  order_detail_id: product.order_detail_id ?? null,
146
146
  discount_list: discountList,
147
+ ...Number(((_f = product.product_sku) == null ? void 0 : _f.open_sold_weight) || 0) === 1 ? { product_sku: JSON.parse(JSON.stringify(product.product_sku)) } : {},
147
148
  new: 0,
148
149
  autoClose: true,
149
150
  _extend: extend
@@ -485,7 +485,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
485
485
  generateIdempotencyToken(): string;
486
486
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
487
487
  createOrder(params: CommitOrderParams['query']): {
488
- type: "appointment_booking" | "virtual";
488
+ type: "virtual" | "appointment_booking";
489
489
  platform: string;
490
490
  sales_channel: string;
491
491
  order_sales_channel: string;
@@ -3629,7 +3629,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
3629
3629
  tempOrder,
3630
3630
  cacheId: (params == null ? void 0 : params.cacheId) ?? this.cacheId,
3631
3631
  platform: (params == null ? void 0 : params.platform) || ((_a = this.otherParams) == null ? void 0 : _a.platform),
3632
- businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
3632
+ businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code) || tempOrder.business_code,
3633
3633
  channel: params == null ? void 0 : params.channel,
3634
3634
  type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
3635
3635
  summary: latestSummary,
@@ -167,6 +167,11 @@ export declare class OrderModule extends BaseModule implements Module {
167
167
  private syncOrdersMap;
168
168
  private getOrderMapKey;
169
169
  private isBlankIdentityValue;
170
+ /**
171
+ * `/sales/draft` 的旧调用方可能把未设置的 business_code 传成空串。
172
+ * 对同一真实订单,空值不能覆盖已有的分类,否则 booking 查询会把该订单从 Party 列表过滤掉。
173
+ */
174
+ private preserveExistingBusinessCodeForDraft;
170
175
  private getOrderIdentityEntries;
171
176
  private getOrderIdentityKeys;
172
177
  private getOrderDateKey;
@@ -1090,7 +1090,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1090
1090
  memoryDraftCount: memoryDraftMap.size,
1091
1091
  sqliteOnlyDraftCount: draftMap.size - memoryDraftMap.size
1092
1092
  });
1093
- const patchedOrders = [...draftMap.values()];
1094
1093
  const mergeActions = {};
1095
1094
  const updatedList = this.store.list.filter((order) => this.shouldKeepOrderInMemory(order));
1096
1095
  const identityKeyToIndex = /* @__PURE__ */ new Map();
@@ -1106,13 +1105,19 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1106
1105
  this.getOrderIdentityMatchKeys(draftOrder)
1107
1106
  );
1108
1107
  if (matchIndex >= 0) {
1109
- const mergedOrder = this.mergeOrderRecords(updatedList[matchIndex], draftOrder);
1108
+ const existingOrder = updatedList[matchIndex];
1109
+ const reconciledDraftOrder = this.preserveExistingBusinessCodeForDraft(
1110
+ existingOrder,
1111
+ draftOrder
1112
+ );
1113
+ const mergedOrder = this.mergeOrderRecords(existingOrder, reconciledDraftOrder);
1110
1114
  const nextOrder = {
1111
1115
  ...mergedOrder,
1112
1116
  need_sync: 0,
1113
1117
  is_draft_order: 1
1114
1118
  };
1115
1119
  updatedList[matchIndex] = nextOrder;
1120
+ draftMap.set(storageKey, reconciledDraftOrder);
1116
1121
  this.registerOrderIdentityKeys(identityKeyToIndex, nextOrder, matchIndex);
1117
1122
  mergeActions[storageKey] = "update";
1118
1123
  continue;
@@ -1122,6 +1127,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1122
1127
  this.registerOrderIdentityKeys(identityKeyToIndex, draftOrder, insertIndex);
1123
1128
  mergeActions[storageKey] = "insert";
1124
1129
  }
1130
+ const patchedOrders = [...draftMap.values()];
1125
1131
  const previousList = this.store.list;
1126
1132
  this.store.list = this.runOrderStoreSelfCheck(updatedList, "upsertLocalDraftOrders.store");
1127
1133
  this.syncOrdersMap();
@@ -1207,6 +1213,22 @@ var OrderModule = class extends import_BaseModule.BaseModule {
1207
1213
  isBlankIdentityValue(value) {
1208
1214
  return value === void 0 || value === null || value === "";
1209
1215
  }
1216
+ /**
1217
+ * `/sales/draft` 的旧调用方可能把未设置的 business_code 传成空串。
1218
+ * 对同一真实订单,空值不能覆盖已有的分类,否则 booking 查询会把该订单从 Party 列表过滤掉。
1219
+ */
1220
+ preserveExistingBusinessCodeForDraft(existingOrder, draftOrder) {
1221
+ const existingBusinessCode = existingOrder.business_code;
1222
+ const draftBusinessCode = draftOrder.business_code;
1223
+ const hasExistingBusinessCode = typeof existingBusinessCode === "string" && existingBusinessCode.trim() !== "";
1224
+ const hasDraftBusinessCode = typeof draftBusinessCode === "string" && draftBusinessCode.trim() !== "";
1225
+ if (!hasExistingBusinessCode || hasDraftBusinessCode)
1226
+ return draftOrder;
1227
+ return {
1228
+ ...draftOrder,
1229
+ business_code: existingBusinessCode
1230
+ };
1231
+ }
1210
1232
  getOrderIdentityEntries(order) {
1211
1233
  if (!order)
1212
1234
  return [];
@@ -1832,7 +1832,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1832
1832
  return this.store.order.saveTempOrderAsDraft({
1833
1833
  cacheId: this.cacheId,
1834
1834
  platform: (params == null ? void 0 : params.platform) ?? ((_a = this.otherParams) == null ? void 0 : _a.platform),
1835
- businessCode: (params == null ? void 0 : params.businessCode) ?? ((_b = this.otherParams) == null ? void 0 : _b.businessCode) ?? ((_c = this.otherParams) == null ? void 0 : _c.business_code),
1835
+ businessCode: (params == null ? void 0 : params.businessCode) || ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
1836
1836
  channel: (params == null ? void 0 : params.channel) ?? this.getSubmitOrderSalesChannel(),
1837
1837
  type: (params == null ? void 0 : params.type) ?? ((_d = this.otherParams) == null ? void 0 : _d.type),
1838
1838
  ...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
@@ -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 | 2 | 1 | 3 | 4 | 5 | 6;
314
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -44,6 +44,7 @@ module.exports = __toCommonJS(addProductDecision_exports);
44
44
  var import_dayjs = __toESM(require("dayjs"));
45
45
  var import_BookingContext = require("../../../modules/BookingContext");
46
46
  var import_transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
47
+ var import_weighingProductSku = require("./weighingProductSku");
47
48
  function needsSpecDetailModal(item) {
48
49
  if (item == null ? void 0 : item.open_sold_weight)
49
50
  return true;
@@ -281,11 +282,14 @@ function buildBasePayloadFromCacheItem(cacheItem, ctx) {
281
282
  const quantity = (ctx == null ? void 0 : ctx.quantity) != null && ctx.quantity > 0 ? ctx.quantity : ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) ?? 1;
282
283
  const resolvedPid = (cacheItem == null ? void 0 : cacheItem.product_id) ?? (cacheItem == null ? void 0 : cacheItem.id);
283
284
  const extend = (cacheItem == null ? void 0 : cacheItem._extend) || {};
285
+ const productSku = (0, import_weighingProductSku.buildProductSkuFromCacheItem)(cacheItem);
284
286
  return {
285
287
  id: (cacheItem == null ? void 0 : cacheItem.id) ?? (cacheItem == null ? void 0 : cacheItem.product_id),
286
288
  product_id: resolvedPid,
287
289
  variant_id: (other == null ? void 0 : other.product_variant_id) ?? (other == null ? void 0 : other.variant_id) ?? 0,
288
290
  quantity,
291
+ // 规格弹窗本次选择是 option 权威源,避免目录/旧订单里的空 option 覆盖它。
292
+ product_sku: productSku ? { ...productSku, option: (other == null ? void 0 : other.option) || [] } : void 0,
289
293
  option: (other == null ? void 0 : other.option) || [],
290
294
  bundle: (other == null ? void 0 : other.bundle) || ((_c = extend == null ? void 0 : extend.skuValue) == null ? void 0 : _c.bundle) || ((_d = extend == null ? void 0 : extend._skuValue) == null ? void 0 : _d.bundle) || [],
291
295
  unique: other == null ? void 0 : other.unique,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 将规格弹窗的称重结果写入订单行权威字段 product_sku。
3
+ * 商品目录已有的 SKU 字段会保留,本次称重结果只覆盖运行态称重字段。
4
+ */
5
+ export declare function buildProductSkuFromCacheItem(cacheItem: Record<string, any> | null | undefined): Record<string, any> | undefined;
@@ -0,0 +1,63 @@
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
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.272",
4
+ "version": "2.2.273",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",