@pisell/pisellos 2.2.188 → 2.2.190

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 (36) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/index.d.ts +1 -0
  3. package/dist/modules/Order/index.js +53 -45
  4. package/dist/modules/Order/types.d.ts +2 -0
  5. package/dist/modules/Order/utils.js +3 -1
  6. package/dist/solution/BaseSales/index.js +61 -53
  7. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -2
  8. package/dist/solution/BookingByStep/index.d.ts +1 -1
  9. package/dist/solution/BookingTicket/index.d.ts +16 -1
  10. package/dist/solution/BookingTicket/index.js +117 -6
  11. package/dist/solution/BookingTicket/types.d.ts +48 -0
  12. package/dist/solution/BookingTicket/types.js +5 -1
  13. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  14. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +394 -0
  15. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  16. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  17. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  18. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  19. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  20. package/lib/modules/Order/index.d.ts +1 -0
  21. package/lib/modules/Order/index.js +15 -10
  22. package/lib/modules/Order/types.d.ts +2 -0
  23. package/lib/modules/Order/utils.js +1 -0
  24. package/lib/solution/BaseSales/index.js +12 -4
  25. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -2
  26. package/lib/solution/BookingByStep/index.d.ts +1 -1
  27. package/lib/solution/BookingTicket/index.d.ts +16 -1
  28. package/lib/solution/BookingTicket/index.js +56 -0
  29. package/lib/solution/BookingTicket/types.d.ts +48 -0
  30. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  31. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +166 -0
  32. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  33. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
  34. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  35. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
  36. package/package.json +1 -1
@@ -607,7 +607,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
607
607
  };
608
608
  externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
609
609
  if (params.forceRemote) {
610
- _context5.next = 36;
610
+ _context5.next = 35;
611
611
  break;
612
612
  }
613
613
  if (!(params.orderId !== undefined)) {
@@ -650,59 +650,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
650
650
  _context5.t0 = _context5.t1;
651
651
  case 26:
652
652
  localRecord = _context5.t0;
653
- debugger;
654
653
  if (!localRecord) {
655
- _context5.next = 36;
654
+ _context5.next = 35;
656
655
  break;
657
656
  }
658
- _context5.next = 31;
657
+ _context5.next = 30;
659
658
  return this.store.order.hydrateTempOrderFromRecord(localRecord, {
660
659
  recalcOnHydrate: false
661
660
  });
662
- case 31:
661
+ case 30:
663
662
  _sales = _context5.sent;
664
663
  this.currentSalesDetail = _sales;
665
- _context5.next = 35;
664
+ _context5.next = 34;
666
665
  return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
667
666
  sales: _sales
668
667
  });
669
- case 35:
668
+ case 34:
670
669
  return _context5.abrupt("return", _sales);
671
- case 36:
670
+ case 35:
672
671
  if (!(params.orderId === undefined || params.orderId === null)) {
673
- _context5.next = 38;
672
+ _context5.next = 37;
674
673
  break;
675
674
  }
676
675
  throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
677
- case 38:
678
- _context5.next = 40;
676
+ case 37:
677
+ _context5.next = 39;
679
678
  return this.store.order.getOrderInfoByRemote(Number(params.orderId));
680
- case 40:
679
+ case 39:
681
680
  res = _context5.sent;
682
681
  if (!(!res || res.code !== 200)) {
683
- _context5.next = 44;
682
+ _context5.next = 43;
684
683
  break;
685
684
  }
686
685
  message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
687
686
  throw new Error(message);
688
- case 44:
689
- _context5.next = 46;
687
+ case 43:
688
+ _context5.next = 45;
690
689
  return this.store.order.hydrateTempOrderFromRecord(res.data, {
691
690
  recalcOnHydrate: false
692
691
  });
693
- case 46:
692
+ case 45:
694
693
  sales = _context5.sent;
695
- _context5.next = 49;
694
+ _context5.next = 48;
696
695
  return this.store.order.saveDraft();
697
- case 49:
696
+ case 48:
698
697
  this.currentSalesDetail = sales;
699
- _context5.next = 52;
698
+ _context5.next = 51;
700
699
  return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
701
700
  sales: sales
702
701
  });
703
- case 52:
702
+ case 51:
704
703
  return _context5.abrupt("return", sales);
705
- case 53:
704
+ case 52:
706
705
  case "end":
707
706
  return _context5.stop();
708
707
  }
@@ -1790,7 +1789,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1790
1789
  key: "submitSalesOrder",
1791
1790
  value: (function () {
1792
1791
  var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
1793
- var _this$otherParams6, _this$otherParams7, _this$otherParams8;
1792
+ var _this$otherParams6, _this$otherParams7, _this$otherParams8, _this$otherParams9;
1794
1793
  var inferredPaymentStatus, submitParams;
1795
1794
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1796
1795
  while (1) switch (_context18.prev = _context18.next) {
@@ -1806,9 +1805,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1806
1805
  submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread({
1807
1806
  cacheId: this.cacheId,
1808
1807
  platform: (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform,
1809
- businessCode: (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode,
1808
+ 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),
1810
1809
  channel: this.getSubmitOrderSalesChannel(),
1811
- type: (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.type
1810
+ type: (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type
1812
1811
  }, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
1813
1812
  payments: params.payments
1814
1813
  } : {}), inferredPaymentStatus !== undefined ? {
@@ -1848,8 +1847,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1848
1847
  key: "syncPaymentsToOrder",
1849
1848
  value: function () {
1850
1849
  var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
1851
- var _params$channel;
1852
- var channel, syncParams, syncState, payments, syncResult;
1850
+ var _ref9, _params$businessCode, _this$otherParams10, _this$otherParams11, _params$channel;
1851
+ var businessCode, channel, syncParams, syncState, payments, syncResult;
1853
1852
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1854
1853
  while (1) switch (_context19.prev = _context19.next) {
1855
1854
  case 0:
@@ -1859,32 +1858,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1859
1858
  }
1860
1859
  throw new Error('order 模块未初始化');
1861
1860
  case 2:
1861
+ businessCode = (_ref9 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.businessCode) !== null && _ref9 !== void 0 ? _ref9 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.business_code;
1862
1862
  channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
1863
- syncParams = _objectSpread(_objectSpread({}, params), channel !== undefined ? {
1863
+ syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
1864
+ businessCode: businessCode
1865
+ } : {}), channel !== undefined ? {
1864
1866
  channel: channel
1865
1867
  } : {});
1866
1868
  syncState = this.store.order.getOrderSyncState();
1867
1869
  if (!(params.submitWhenPaid && syncState === 'submitting')) {
1868
- _context19.next = 7;
1870
+ _context19.next = 8;
1869
1871
  break;
1870
1872
  }
1871
1873
  return _context19.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
1872
- case 7:
1874
+ case 8:
1873
1875
  payments = params.payments || [];
1874
- _context19.next = 10;
1876
+ _context19.next = 11;
1875
1877
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
1876
1878
  payments: payments,
1877
1879
  params: syncParams,
1878
1880
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
1879
1881
  orderSnapshot: this.store.order.getOrderSnapshot()
1880
1882
  });
1881
- case 10:
1882
- _context19.prev = 10;
1883
- _context19.next = 13;
1883
+ case 11:
1884
+ _context19.prev = 11;
1885
+ _context19.next = 14;
1884
1886
  return this.store.order.syncPaymentsToOrder(syncParams);
1885
- case 13:
1887
+ case 14:
1886
1888
  syncResult = _context19.sent;
1887
- _context19.next = 16;
1889
+ _context19.next = 17;
1888
1890
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
1889
1891
  ok: true,
1890
1892
  syncResult: syncResult,
@@ -1893,12 +1895,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1893
1895
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
1894
1896
  orderSnapshot: this.store.order.getOrderSnapshot()
1895
1897
  });
1896
- case 16:
1898
+ case 17:
1897
1899
  return _context19.abrupt("return", syncResult);
1898
- case 19:
1899
- _context19.prev = 19;
1900
- _context19.t0 = _context19["catch"](10);
1901
- _context19.next = 23;
1900
+ case 20:
1901
+ _context19.prev = 20;
1902
+ _context19.t0 = _context19["catch"](11);
1903
+ _context19.next = 24;
1902
1904
  return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
1903
1905
  ok: false,
1904
1906
  error: _context19.t0,
@@ -1907,13 +1909,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1907
1909
  amountSnapshot: this.store.order.getOrderAmountSnapshot(),
1908
1910
  orderSnapshot: this.store.order.getOrderSnapshot()
1909
1911
  });
1910
- case 23:
1911
- throw _context19.t0;
1912
1912
  case 24:
1913
+ throw _context19.t0;
1914
+ case 25:
1913
1915
  case "end":
1914
1916
  return _context19.stop();
1915
1917
  }
1916
- }, _callee19, this, [[10, 19]]);
1918
+ }, _callee19, this, [[11, 20]]);
1917
1919
  }));
1918
1920
  function syncPaymentsToOrder(_x15) {
1919
1921
  return _syncPaymentsToOrder.apply(this, arguments);
@@ -1939,10 +1941,16 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1939
1941
  }, {
1940
1942
  key: "addOrderPayment",
1941
1943
  value: function addOrderPayment(payment) {
1942
- var _this6 = this;
1944
+ var _this$otherParams12,
1945
+ _this6 = this;
1943
1946
  if (!this.store.order) throw new Error('order 模块未初始化');
1944
1947
  var paymentRecord = payment;
1945
1948
  var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
1949
+ debugger;
1950
+ var shopWalletPassId = (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.shop_wallet_pass_id;
1951
+ if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
1952
+ metadata.shop_wallet_pass_id = shopWalletPassId;
1953
+ }
1946
1954
  if (!metadata.unique_identification_number) {
1947
1955
  metadata.unique_identification_number = createUuidV4();
1948
1956
  }
@@ -2051,7 +2059,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2051
2059
  key: "initWalletData",
2052
2060
  value: function () {
2053
2061
  var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2054
- var _params$order_wait_pa, _ref9, _tempOrder$is_price_i;
2062
+ var _params$order_wait_pa, _ref10, _tempOrder$is_price_i;
2055
2063
  var snapshot, tempOrder, amount, walletBusinessData, result;
2056
2064
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2057
2065
  while (1) switch (_context20.prev = _context20.next) {
@@ -2094,7 +2102,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2094
2102
  },
2095
2103
  products: this.getWalletProductList(),
2096
2104
  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),
2097
- is_price_include_tax: (_ref9 = (_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 && _ref9 !== void 0 ? _ref9 : 1
2105
+ is_price_include_tax: (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : 1
2098
2106
  }, snapshot.identity.orderId ? {
2099
2107
  payment_order_id: String(snapshot.identity.orderId)
2100
2108
  } : {});
@@ -2210,7 +2218,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2210
2218
  key: "sendCustomerPayLink",
2211
2219
  value: (function () {
2212
2220
  var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2213
- var orderIds, _ref10, _ref11, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2221
+ var orderIds, _ref11, _ref12, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
2214
2222
  return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2215
2223
  while (1) switch (_context22.prev = _context22.next) {
2216
2224
  case 0:
@@ -2231,7 +2239,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2231
2239
  });
2232
2240
  case 6:
2233
2241
  submitResult = _context22.sent;
2234
- orderId = (_ref10 = (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref10 !== void 0 ? _ref10 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2242
+ orderId = (_ref11 = (_ref12 = (_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 && _ref12 !== void 0 ? _ref12 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref11 !== void 0 ? _ref11 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
2235
2243
  if (orderId) {
2236
2244
  _context22.next = 10;
2237
2245
  break;
@@ -2588,13 +2596,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2588
2596
  key: "getProductList",
2589
2597
  value: function () {
2590
2598
  var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2591
- var _this$otherParams9;
2599
+ var _this$otherParams13;
2592
2600
  var menu_list_ids, _this$store$products, res;
2593
2601
  return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2594
2602
  while (1) switch (_context30.prev = _context30.next) {
2595
2603
  case 0:
2596
2604
  // 可以直接通过配置里的 menu 读取
2597
- menu_list_ids = ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 || (_this$otherParams9 = _this$otherParams9.dineInConfig) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9['menu.associated_menus'].map(function (n) {
2605
+ menu_list_ids = ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 || (_this$otherParams13 = _this$otherParams13.dineInConfig) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13['menu.associated_menus'].map(function (n) {
2598
2606
  return Number(n.value);
2599
2607
  })) || [];
2600
2608
  _context30.prev = 1;
@@ -2632,14 +2640,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
2632
2640
  key: "setOtherParams",
2633
2641
  value: function () {
2634
2642
  var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
2635
- var _ref12,
2636
- _ref12$cover,
2643
+ var _ref13,
2644
+ _ref13$cover,
2637
2645
  cover,
2638
2646
  _args31 = arguments;
2639
2647
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2640
2648
  while (1) switch (_context31.prev = _context31.next) {
2641
2649
  case 0:
2642
- _ref12 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref12$cover = _ref12.cover, cover = _ref12$cover === void 0 ? false : _ref12$cover;
2650
+ _ref13 = _args31.length > 1 && _args31[1] !== undefined ? _args31[1] : {}, _ref13$cover = _ref13.cover, cover = _ref13$cover === void 0 ? false : _ref13$cover;
2643
2651
  if (cover) {
2644
2652
  this.otherParams = params;
2645
2653
  } else {
@@ -4,6 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  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; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  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); }
7
+ import { composeLinePrice, sumOptionUnitPrice } from "../../../modules/Order/utils";
7
8
  import { buildManualProductDiscountItem, mergeManualProductDiscountIntoList, resolveManualDiscountOriginTotal, resolveManualDiscountReasonFromSources, shouldBuildManualProductDiscount } from "../../../modules/Order/utils/manualProductDiscount";
8
9
  function toNumber(value) {
9
10
  var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
@@ -123,6 +124,16 @@ export function transformBaseProductToOrderProduct(params) {
123
124
  discountway: (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.discountway,
124
125
  discount_per: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_per
125
126
  })) : payload.discount_list || [];
127
+
128
+ // v2:source 不含 option;main_product_* 含 option(与 normalizeOrderProduct 一致)
129
+ var optionSum = sumOptionUnitPrice(productOptionItem).toNumber();
130
+ var mainProductOriginalPrice = toPriceString(Number(sourceProductPrice) + optionSum);
131
+ var bundleOnlyComposite = composeLinePrice({
132
+ mainPrice: 0,
133
+ bundle: productBundle
134
+ });
135
+ var derivedMainSelling = Number(lineCompositeTotal) - Number(bundleOnlyComposite);
136
+ var mainProductSellingPrice = toPriceString(Number.isFinite(derivedMainSelling) && derivedMainSelling >= 0 ? derivedMainSelling : Number(mainProductOriginalPrice));
126
137
  var metadata = _objectSpread(_objectSpread({
127
138
  unique: payload.unique,
128
139
  session: payload.session,
@@ -135,8 +146,9 @@ export function transformBaseProductToOrderProduct(params) {
135
146
  source_shop_id: payload.source_shop_id,
136
147
  origin: origin,
137
148
  source_product_price: sourceProductPrice,
138
- main_product_selling_price: sourceProductPrice,
139
- main_product_original_price: sourceProductPrice
149
+ main_product_selling_price: mainProductSellingPrice,
150
+ main_product_original_price: mainProductOriginalPrice,
151
+ price_schema_version: 2
140
152
  }, hasPriceOverride ? {
141
153
  price_override: String(payload.price_override),
142
154
  is_manual_discount: 1
@@ -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 | 3 | 5 | 4 | 6;
314
+ weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -7,6 +7,7 @@ import { BaseSalesImpl } from '../BaseSales';
7
7
  import type { BaseSalesScanCodeResult } from '../BaseSales/types';
8
8
  import type { ISalesDetail } from '../BaseSales/utils/parseSalesResponse';
9
9
  import type { LoadSalesDetailParams } from '../../modules/Order/types';
10
+ import type { GlobalScanHandleResult, GlobalScanHostBridge } from './types';
10
11
  import { AddProductDecideContext, AddProductRequiresDetailPayload } from './utils/addProductDecision';
11
12
  import { type BuildCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildCacheItemFromOrderLine';
12
13
  import { type BuildNormalProductCacheItemFromOrderLineInput } from '../../modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine';
@@ -278,7 +279,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
278
279
  * 获取当前的客户搜索条件
279
280
  * @returns 当前搜索条件
280
281
  */
281
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
282
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
282
283
  /**
283
284
  * 获取客户列表状态(包含滚动加载相关状态)
284
285
  * @returns 客户状态
@@ -441,6 +442,20 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
441
442
  buildNormalProductCacheItemFromOrderLine(input: BuildNormalProductCacheItemFromOrderLineInput): Record<string, any>;
442
443
  /** 文档别名:与 OrderModule.updateOrderProduct 一致。 */
443
444
  updateProductInOrder(params: UpdateOrderProductParams): Promise<OrderProduct[]>;
445
+ /**
446
+ * 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
447
+ * UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
448
+ *
449
+ * @example
450
+ * ```ts
451
+ * await bookingTicket.handleGlobalScanCode(payload.data, {
452
+ * openProductDetail: uiHosts.openProductDetail,
453
+ * confirmDetail: cart.confirmDetail,
454
+ * openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
455
+ * });
456
+ * ```
457
+ */
458
+ handleGlobalScanCode(code: string, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
444
459
  /**
445
460
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
446
461
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -37,6 +37,8 @@ import Scan from "./utils/scan";
37
37
  import { formatOrderCustomerPatch } from "./utils/orderCustomer";
38
38
  import { handleGlobalScan, handleCustomerScan, handleUniversalScan } from "./utils/scan/handleScan";
39
39
  import scanCache from "./utils/scan/scanCache";
40
+ import { formatGlobalScanResult } from "./utils/scan/formatGlobalScan";
41
+ import { applyGlobalScan } from "./utils/scan/applyGlobalScan";
40
42
  import { buildCartView } from "./utils/cartView";
41
43
  import { buildCacheItemFromCartDetail, buildCacheItemFromDetail, buildRequiresDetailPayload as _buildRequiresDetailPayload, decideAddProduct as decideAddProductUtil, decideAfterDetail as decideAfterDetailUtil, decideAutoClose as decideAutoCloseUtil, getIsEject as getIsEjectUtil, getIsOnlySession as getIsOnlySessionUtil, transformDetailToProductAndBooking as transformDetailToProductAndBookingUtil } from "./utils/addProductDecision";
42
44
  import { buildCacheItemFromOrderLine as buildCacheItemFromOrderLineUtil } from "../../modules/BookingContext/utils/buildCacheItemFromOrderLine";
@@ -1738,6 +1740,115 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1738
1740
  }
1739
1741
  return updateProductInOrder;
1740
1742
  }()
1743
+ /**
1744
+ * 全局扫码 pubsub 入口:解析码值 → 搜索 → 业务分发(客户 / 加车 / 开单)。
1745
+ * UI 层在 pubsub 订阅回调里注入 `bridge`(uiHosts / action / cart.confirm*)。
1746
+ *
1747
+ * @example
1748
+ * ```ts
1749
+ * await bookingTicket.handleGlobalScanCode(payload.data, {
1750
+ * openProductDetail: uiHosts.openProductDetail,
1751
+ * confirmDetail: cart.confirmDetail,
1752
+ * openOrder: ({ order_id }) => action({ type: 'pisell1.handleOpenCachedBigSale', data: { order_id } }),
1753
+ * });
1754
+ * ```
1755
+ */
1756
+ )
1757
+ }, {
1758
+ key: "handleGlobalScanCode",
1759
+ value: (function () {
1760
+ var _handleGlobalScanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(code, bridge) {
1761
+ var _this6 = this;
1762
+ var trimmed, _bridge$onNotify, _bridge$refresh, localSearch, scanCallback, raw, formatted, _bridge$onNotify2, _result7, _bridge$onNotify3;
1763
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1764
+ while (1) switch (_context23.prev = _context23.next) {
1765
+ case 0:
1766
+ trimmed = typeof code === 'string' ? code.trim() : '';
1767
+ if (trimmed) {
1768
+ _context23.next = 4;
1769
+ break;
1770
+ }
1771
+ bridge === null || bridge === void 0 || (_bridge$onNotify = bridge.onNotify) === null || _bridge$onNotify === void 0 || _bridge$onNotify.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
1772
+ return _context23.abrupt("return", {
1773
+ status: 'failed',
1774
+ reason: 'empty_code'
1775
+ });
1776
+ case 4:
1777
+ _context23.prev = 4;
1778
+ localSearch = function localSearch(v) {
1779
+ return _this6.store.products.findProductsByCodeOrBarcode(v);
1780
+ };
1781
+ scanCallback = handleGlobalScan(this.request, localSearch);
1782
+ _context23.next = 9;
1783
+ return scanCallback({
1784
+ type: 'nativeScanner',
1785
+ value: trimmed
1786
+ });
1787
+ case 9:
1788
+ raw = _context23.sent;
1789
+ formatted = formatGlobalScanResult(raw, trimmed);
1790
+ if (formatted) {
1791
+ _context23.next = 14;
1792
+ break;
1793
+ }
1794
+ bridge === null || bridge === void 0 || (_bridge$onNotify2 = bridge.onNotify) === null || _bridge$onNotify2 === void 0 || _bridge$onNotify2.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
1795
+ return _context23.abrupt("return", {
1796
+ status: 'failed',
1797
+ reason: 'not_found'
1798
+ });
1799
+ case 14:
1800
+ _context23.next = 16;
1801
+ return applyGlobalScan({
1802
+ setOrderCustomer: function setOrderCustomer(customer) {
1803
+ return _this6.setOrderCustomer(customer);
1804
+ },
1805
+ getOrderCustomerSnapshot: function getOrderCustomerSnapshot() {
1806
+ return _this6.getOrderCustomerSnapshot();
1807
+ },
1808
+ getBusinessCode: function getBusinessCode() {
1809
+ var _this6$otherParams;
1810
+ return (_this6$otherParams = _this6.otherParams) === null || _this6$otherParams === void 0 ? void 0 : _this6$otherParams.businessCode;
1811
+ },
1812
+ buildAddProductCtx: function buildAddProductCtx(extra) {
1813
+ return _this6.buildAddProductCtx(extra);
1814
+ },
1815
+ decideAddProduct: function decideAddProduct(item, options) {
1816
+ return _this6.decideAddProduct(item, options);
1817
+ },
1818
+ decideAfterDetail: function decideAfterDetail(cacheItem, options) {
1819
+ return _this6.decideAfterDetail(cacheItem, options);
1820
+ },
1821
+ transformDetailToProductAndBooking: function transformDetailToProductAndBooking(input) {
1822
+ return _this6.transformDetailToProductAndBooking(input);
1823
+ },
1824
+ addProductToOrder: function addProductToOrder(product, booking) {
1825
+ return _this6.addProductToOrder(product, booking);
1826
+ }
1827
+ }, formatted, bridge);
1828
+ case 16:
1829
+ _result7 = _context23.sent;
1830
+ bridge === null || bridge === void 0 || (_bridge$refresh = bridge.refresh) === null || _bridge$refresh === void 0 || _bridge$refresh.call(bridge);
1831
+ return _context23.abrupt("return", _result7);
1832
+ case 21:
1833
+ _context23.prev = 21;
1834
+ _context23.t0 = _context23["catch"](4);
1835
+ console.error('[BookingTicket] handleGlobalScanCode failed', _context23.t0);
1836
+ bridge === null || bridge === void 0 || (_bridge$onNotify3 = bridge.onNotify) === null || _bridge$onNotify3 === void 0 || _bridge$onNotify3.call(bridge, 'fail', 'pisell2.text.scan-global-failed');
1837
+ return _context23.abrupt("return", {
1838
+ status: 'failed',
1839
+ reason: 'not_found'
1840
+ });
1841
+ case 26:
1842
+ case "end":
1843
+ return _context23.stop();
1844
+ }
1845
+ }, _callee23, this, [[4, 21]]);
1846
+ }));
1847
+ function handleGlobalScanCode(_x18, _x19) {
1848
+ return _handleGlobalScanCode.apply(this, arguments);
1849
+ }
1850
+ return handleGlobalScanCode;
1851
+ }()
1741
1852
  /**
1742
1853
  * 销毁模块:先调用父类(销毁所有 store 内子模块 + emit destroy + super.destroy()),
1743
1854
  * 再清理 BookingTicket 自有资源(scan 监听 + scan 内存缓存)。
@@ -1746,12 +1857,12 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1746
1857
  }, {
1747
1858
  key: "destroy",
1748
1859
  value: (function () {
1749
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1860
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1750
1861
  var _this$scan;
1751
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1752
- while (1) switch (_context23.prev = _context23.next) {
1862
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1863
+ while (1) switch (_context24.prev = _context24.next) {
1753
1864
  case 0:
1754
- _context23.next = 2;
1865
+ _context24.next = 2;
1755
1866
  return _get(_getPrototypeOf(BookingTicketImpl.prototype), "destroy", this).call(this);
1756
1867
  case 2:
1757
1868
  try {
@@ -1762,9 +1873,9 @@ export var BookingTicketImpl = /*#__PURE__*/function (_BaseSalesImpl) {
1762
1873
  scanCache.clear();
1763
1874
  case 4:
1764
1875
  case "end":
1765
- return _context23.stop();
1876
+ return _context24.stop();
1766
1877
  }
1767
- }, _callee23, this);
1878
+ }, _callee24, this);
1768
1879
  }));
1769
1880
  function destroy() {
1770
1881
  return _destroy.apply(this, arguments);
@@ -134,3 +134,51 @@ export interface BookingTicketCustomerView {
134
134
  export interface BookingTicketProductCatalogView {
135
135
  products: ProductData[];
136
136
  }
137
+ /** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
138
+ export interface GlobalScanHostBridge {
139
+ openProductDetail?: (payload: Record<string, any>) => Promise<any | null>;
140
+ openBookingEdit?: (payload: Record<string, any>) => Promise<any | null>;
141
+ confirmDetail?: (input: {
142
+ item: any;
143
+ detailResult: {
144
+ e: any;
145
+ extension_type?: any;
146
+ detail?: any;
147
+ };
148
+ options?: Record<string, any>;
149
+ }) => Promise<any>;
150
+ confirmBookingEdit?: (input: {
151
+ cacheItem: any;
152
+ options?: Record<string, any>;
153
+ }) => Promise<any>;
154
+ openOrder?: (data: {
155
+ order_id: number;
156
+ business_code?: string;
157
+ }) => void;
158
+ /**
159
+ * walk-in 扫 walletPass:直接核销优惠码(对齐 SaleDetail Voucher.handleApplyCode / cart.scanCode)。
160
+ */
161
+ applyPromotionCode?: (code: string, customerId?: number) => Promise<{
162
+ isAvailable?: boolean;
163
+ type?: string;
164
+ unavailableReason?: string;
165
+ }>;
166
+ onNotify?: (type: 'success' | 'fail' | 'info', messageKey?: string) => void;
167
+ refresh?: () => void;
168
+ }
169
+ /** handleGlobalScanCode 结构化返回 */
170
+ export type GlobalScanHandleResult = {
171
+ status: 'success';
172
+ kind: 'customer' | 'products' | 'promotion';
173
+ meta?: {
174
+ count?: number;
175
+ };
176
+ } | {
177
+ status: 'pending';
178
+ kind: 'openOrder' | 'requiresDetail' | 'requiresBookingEdit';
179
+ } | {
180
+ status: 'cancelled';
181
+ } | {
182
+ status: 'failed';
183
+ reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge';
184
+ };
@@ -77,4 +77,8 @@ export var BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
77
77
 
78
78
  /**
79
79
  * BookingTicket 当前已加载的商品池视图。
80
- */
80
+ */
81
+
82
+ /** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
83
+
84
+ /** handleGlobalScanCode 结构化返回 */
@@ -0,0 +1,36 @@
1
+ import type { GlobalScanHandleResult, GlobalScanHostBridge, ICustomer } from '../../types';
2
+ import type { AddProductDecision } from '../addProductDecision';
3
+ import { GlobalScanFormattedResult } from './formatGlobalScan';
4
+ /** applyGlobalScan 所需的 BookingTicket 运行时能力 */
5
+ export interface GlobalScanApplyHost {
6
+ setOrderCustomer(customer: ICustomer | null): void;
7
+ getOrderCustomerSnapshot(): ICustomer | null;
8
+ getBusinessCode(): string | undefined;
9
+ buildAddProductCtx(extra?: Record<string, any>): Record<string, any>;
10
+ decideAddProduct(item: any, options?: Record<string, any>): AddProductDecision;
11
+ decideAfterDetail(cacheItem: any, options?: Record<string, any>): AddProductDecision;
12
+ transformDetailToProductAndBooking(input: {
13
+ item: any;
14
+ cacheItem?: any;
15
+ detailResult?: {
16
+ e: any;
17
+ extension_type?: any;
18
+ detail?: any;
19
+ };
20
+ options?: Record<string, any>;
21
+ }): {
22
+ product: any;
23
+ booking?: any;
24
+ cacheItem: any;
25
+ };
26
+ addProductToOrder(product: any, booking?: any): Promise<any>;
27
+ }
28
+ /**
29
+ * 应用全局扫码格式化结果:设客户 / 加车 / 开单 / 弹窗链。
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const result = await applyGlobalScan(bookingTicket, formatted, bridge);
34
+ * ```
35
+ */
36
+ export declare function applyGlobalScan(host: GlobalScanApplyHost, formatted: GlobalScanFormattedResult, bridge?: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;