@pisell/pisellos 0.0.551 → 0.0.552

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.
@@ -1,9 +0,0 @@
1
- // 导出评估器
2
- export { PromotionEvaluator } from "./evaluator";
3
-
4
- // 导出适配器
5
- export { PromotionAdapter } from "./adapter";
6
- export { default } from "./adapter";
7
-
8
- // 导出策略配置示例常量
9
- export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore, ModuleOptions } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
- import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, HolderModuleAPI, HolderFormMap } from './types';
3
+ import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, IRefreshAllFormRecordsParams, HolderModuleAPI, HolderFormMap } from './types';
4
4
  export * from './types';
5
5
  export * from './utils';
6
6
  export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
@@ -15,6 +15,7 @@ export declare class HolderModule extends BaseModule implements Module, HolderMo
15
15
  private error;
16
16
  /** 已加载过表单数据的 form_id 缓存标记 */
17
17
  private loadedFormIds;
18
+ private window;
18
19
  constructor(name?: string, version?: string);
19
20
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
20
21
  /** 统一提交 formMap,仅此处触发 store changed */
@@ -38,5 +39,10 @@ export declare class HolderModule extends BaseModule implements Module, HolderMo
38
39
  appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
39
40
  removeFormRecord(formId: number | string, formRecordId: number): void;
40
41
  clearFormData(formId?: number | string): void;
42
+ /**
43
+ * 登录后按当前 holderMap 批量刷新所有表单的 records。
44
+ * 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
45
+ */
46
+ refreshAllFormRecords(params?: IRefreshAllFormRecordsParams): Promise<HolderFormMap>;
41
47
  storeChange(path?: string): void;
42
48
  }
@@ -1,4 +1,8 @@
1
1
  var _excluded = ["form_id", "shop_id", "num", "skip", "customer_id"];
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
5
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
7
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
8
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -28,7 +32,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
28
32
  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); }
29
33
  import { cloneDeep } from 'lodash-es';
30
34
  import { BaseModule } from "../BaseModule";
31
- import { createEmptyFormItemData, getFormIdFromHolderConfig, getProductHolderConfig, normalizeFormId } from "./utils";
35
+ import { createEmptyFormItemData, getFormIdFromHolderConfig, getProductHolderConfig, normalizeFormId, resolveFormMetaFromHolderItem } from "./utils";
32
36
  export * from "./types";
33
37
  export * from "./utils";
34
38
  export var HolderModule = /*#__PURE__*/function (_BaseModule) {
@@ -49,6 +53,7 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
49
53
  _defineProperty(_assertThisInitialized(_this), "error", null);
50
54
  /** 已加载过表单数据的 form_id 缓存标记 */
51
55
  _defineProperty(_assertThisInitialized(_this), "loadedFormIds", new Set());
56
+ _defineProperty(_assertThisInitialized(_this), "window", void 0);
52
57
  return _this;
53
58
  }
54
59
  _createClass(HolderModule, [{
@@ -217,7 +222,8 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
217
222
  key: "fetchRecords",
218
223
  value: function () {
219
224
  var _fetchRecords = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
220
- var url, _ref3, form_id, shop_id, num, skip, customer_id, rest, formId, useCache, _res$data, res, records, nextFormMap;
225
+ var _this$window, _this$window$getLocal;
226
+ var url, _ref3, form_id, shop_id, num, skip, customer_id, rest, formId, useCache, customer, customerId, _res$data, res, records, nextFormMap;
221
227
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
222
228
  while (1) switch (_context3.prev = _context3.next) {
223
229
  case 0:
@@ -225,12 +231,20 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
225
231
  _ref3 = params.query || {}, form_id = _ref3.form_id, shop_id = _ref3.shop_id, num = _ref3.num, skip = _ref3.skip, customer_id = _ref3.customer_id, rest = _objectWithoutProperties(_ref3, _excluded);
226
232
  formId = normalizeFormId(form_id);
227
233
  useCache = params.useCache !== false;
234
+ customer = JSON.parse(((_this$window = this.window) === null || _this$window === void 0 || (_this$window$getLocal = _this$window.getLocalStorage) === null || _this$window$getLocal === void 0 ? void 0 : _this$window$getLocal.call(_this$window, 'customer')) || '{}');
235
+ customerId = customer_id !== null && customer_id !== void 0 ? customer_id : customer.id;
236
+ if (customerId) {
237
+ _context3.next = 8;
238
+ break;
239
+ }
240
+ return _context3.abrupt("return", []);
241
+ case 8:
228
242
  this.isLoading = true;
229
243
  this.error = null;
230
- _context3.prev = 6;
231
- _context3.next = 9;
244
+ _context3.prev = 10;
245
+ _context3.next = 13;
232
246
  return this.request.get(url, _objectSpread({
233
- customer_id: customer_id,
247
+ customer_id: customerId,
234
248
  form_id: form_id,
235
249
  shop_id: shop_id,
236
250
  num: num || 100,
@@ -239,7 +253,7 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
239
253
  }, rest), {
240
254
  useCache: useCache
241
255
  });
242
- case 9:
256
+ case 13:
243
257
  res = _context3.sent;
244
258
  records = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.list) || [];
245
259
  nextFormMap = _objectSpread({}, this.store.holderMap);
@@ -248,20 +262,20 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
248
262
  });
249
263
  this.commitFormMap(nextFormMap);
250
264
  return _context3.abrupt("return", records);
251
- case 17:
252
- _context3.prev = 17;
253
- _context3.t0 = _context3["catch"](6);
254
- this.error = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
255
- throw _context3.t0;
256
265
  case 21:
257
266
  _context3.prev = 21;
267
+ _context3.t0 = _context3["catch"](10);
268
+ this.error = _context3.t0 instanceof Error ? _context3.t0.message : String(_context3.t0);
269
+ throw _context3.t0;
270
+ case 25:
271
+ _context3.prev = 25;
258
272
  this.isLoading = false;
259
- return _context3.finish(21);
260
- case 24:
273
+ return _context3.finish(25);
274
+ case 28:
261
275
  case "end":
262
276
  return _context3.stop();
263
277
  }
264
- }, _callee3, this, [[6, 17, 21, 24]]);
278
+ }, _callee3, this, [[10, 21, 25, 28]]);
265
279
  }));
266
280
  function fetchRecords(_x4) {
267
281
  return _fetchRecords.apply(this, arguments);
@@ -479,6 +493,131 @@ export var HolderModule = /*#__PURE__*/function (_BaseModule) {
479
493
  this.commitFormMap({});
480
494
  }
481
495
  }
496
+
497
+ /**
498
+ * 登录后按当前 holderMap 批量刷新所有表单的 records。
499
+ * 遍历 holderMap,从 form.form 中读取 form_id、shop_id,结合 customer_id 重新拉取记录。
500
+ */
501
+ }, {
502
+ key: "refreshAllFormRecords",
503
+ value: (function () {
504
+ var _refreshAllFormRecords = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
505
+ var _params$useCache,
506
+ _this4 = this;
507
+ var params,
508
+ customer_id,
509
+ recordsUrl,
510
+ num,
511
+ skip,
512
+ useCache,
513
+ entries,
514
+ url,
515
+ results,
516
+ nextFormMap,
517
+ _args8 = arguments;
518
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
519
+ while (1) switch (_context8.prev = _context8.next) {
520
+ case 0:
521
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
522
+ customer_id = params.customer_id, recordsUrl = params.recordsUrl, num = params.num, skip = params.skip;
523
+ useCache = (_params$useCache = params.useCache) !== null && _params$useCache !== void 0 ? _params$useCache : false;
524
+ if (customer_id) {
525
+ _context8.next = 5;
526
+ break;
527
+ }
528
+ return _context8.abrupt("return", this.getHolderFormMap());
529
+ case 5:
530
+ entries = Object.entries(this.store.holderMap);
531
+ if (entries.length) {
532
+ _context8.next = 8;
533
+ break;
534
+ }
535
+ return _context8.abrupt("return", this.getHolderFormMap());
536
+ case 8:
537
+ url = recordsUrl || '/form/data/v1';
538
+ this.isLoading = true;
539
+ this.error = null;
540
+ _context8.prev = 11;
541
+ _context8.next = 14;
542
+ return Promise.all(entries.map( /*#__PURE__*/function () {
543
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref4) {
544
+ var _ref6, mapKey, item, meta, _res$data2, res;
545
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
546
+ while (1) switch (_context7.prev = _context7.next) {
547
+ case 0:
548
+ _ref6 = _slicedToArray(_ref4, 2), mapKey = _ref6[0], item = _ref6[1];
549
+ meta = resolveFormMetaFromHolderItem(mapKey, item);
550
+ if (meta) {
551
+ _context7.next = 4;
552
+ break;
553
+ }
554
+ return _context7.abrupt("return", null);
555
+ case 4:
556
+ _context7.prev = 4;
557
+ _context7.next = 7;
558
+ return _this4.request.get(url, {
559
+ customer_id: customer_id,
560
+ form_id: meta.form_id,
561
+ shop_id: meta.shop_id,
562
+ num: num || 100,
563
+ skip: skip || 1,
564
+ front_end_cache_id: useCache && _this4.cacheId
565
+ }, {
566
+ useCache: useCache
567
+ });
568
+ case 7:
569
+ res = _context7.sent;
570
+ return _context7.abrupt("return", {
571
+ formId: meta.form_id,
572
+ records: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.list) || []
573
+ });
574
+ case 11:
575
+ _context7.prev = 11;
576
+ _context7.t0 = _context7["catch"](4);
577
+ console.error("[HolderModule] refreshAllFormRecords failed for form ".concat(meta.form_id), _context7.t0);
578
+ return _context7.abrupt("return", null);
579
+ case 15:
580
+ case "end":
581
+ return _context7.stop();
582
+ }
583
+ }, _callee7, null, [[4, 11]]);
584
+ }));
585
+ return function (_x8) {
586
+ return _ref5.apply(this, arguments);
587
+ };
588
+ }()));
589
+ case 14:
590
+ results = _context8.sent;
591
+ nextFormMap = _objectSpread({}, this.store.holderMap);
592
+ results.forEach(function (result) {
593
+ if (!result) return;
594
+ _this4.patchFormMap(nextFormMap, result.formId, {
595
+ records: result.records
596
+ });
597
+ _this4.loadedFormIds.add(result.formId);
598
+ });
599
+ this.commitFormMap(nextFormMap);
600
+ return _context8.abrupt("return", cloneDeep(nextFormMap));
601
+ case 21:
602
+ _context8.prev = 21;
603
+ _context8.t0 = _context8["catch"](11);
604
+ this.error = _context8.t0 instanceof Error ? _context8.t0.message : String(_context8.t0);
605
+ throw _context8.t0;
606
+ case 25:
607
+ _context8.prev = 25;
608
+ this.isLoading = false;
609
+ return _context8.finish(25);
610
+ case 28:
611
+ case "end":
612
+ return _context8.stop();
613
+ }
614
+ }, _callee8, this, [[11, 21, 25, 28]]);
615
+ }));
616
+ function refreshAllFormRecords() {
617
+ return _refreshAllFormRecords.apply(this, arguments);
618
+ }
619
+ return refreshAllFormRecords;
620
+ }())
482
621
  }, {
483
622
  key: "storeChange",
484
623
  value: function storeChange(path) {
@@ -68,7 +68,7 @@ export interface IFetchFormRecordsParams {
68
68
  export interface IAddFormRecordParams {
69
69
  url?: string;
70
70
  body: {
71
- form_id: number | string;
71
+ form_id: number;
72
72
  shop_id: number | string;
73
73
  customer_id?: number;
74
74
  [key: string]: any;
@@ -100,6 +100,13 @@ export interface IEnsureFormByProductParams {
100
100
  shop_id?: number | string;
101
101
  useCache?: boolean;
102
102
  }
103
+ export interface IRefreshAllFormRecordsParams {
104
+ customer_id?: number;
105
+ useCache?: boolean;
106
+ recordsUrl?: string;
107
+ num?: number;
108
+ skip?: number;
109
+ }
103
110
  export interface HolderModuleAPI {
104
111
  getHolderFormMap: () => HolderFormMap;
105
112
  getHolderFormData: (formId: number | string) => IFormItemData | undefined;
@@ -112,4 +119,5 @@ export interface HolderModuleAPI {
112
119
  appendFormRecord: (params: IAppendFormRecordParams) => IFormRecord;
113
120
  removeFormRecord: (formId: number | string, formRecordId: number) => void;
114
121
  clearFormData: (formId?: number | string) => void;
122
+ refreshAllFormRecords: (params?: IRefreshAllFormRecordsParams) => Promise<HolderFormMap>;
115
123
  }
@@ -1,9 +1,13 @@
1
1
  import { ProductData } from '../Product/types';
2
- import { IHolderConfig } from './types';
2
+ import { IFormItemData, IHolderConfig } from './types';
3
3
  export declare function getProductHolderConfig(product?: ProductData | Record<string, any> | null): IHolderConfig | null;
4
- export declare function getFormIdFromHolderConfig(config: IHolderConfig): string;
5
- export declare function normalizeFormId(formId: number | string): string;
4
+ export declare function getFormIdFromHolderConfig(config: IHolderConfig): number;
5
+ export declare function normalizeFormId(formId: number | string): number;
6
6
  export declare function createEmptyFormItemData(): {
7
7
  records: any[];
8
8
  form: Record<string, any>;
9
9
  };
10
+ export declare function resolveFormMetaFromHolderItem(mapKey: string, item: IFormItemData): {
11
+ form_id: string | number;
12
+ shop_id: number | string;
13
+ } | null;
@@ -7,14 +7,28 @@ export function getProductHolderConfig(product) {
7
7
  return config;
8
8
  }
9
9
  export function getFormIdFromHolderConfig(config) {
10
- return String(config === null || config === void 0 ? void 0 : config.resource_id);
10
+ return Number(config === null || config === void 0 ? void 0 : config.resource_id);
11
11
  }
12
12
  export function normalizeFormId(formId) {
13
- return String(formId);
13
+ return Number(formId);
14
14
  }
15
15
  export function createEmptyFormItemData() {
16
16
  return {
17
17
  records: [],
18
18
  form: {}
19
19
  };
20
+ }
21
+ export function resolveFormMetaFromHolderItem(mapKey, item) {
22
+ var _ref, _ref2, _nestedForm$id, _nestedForm$shop_id;
23
+ var formInfo = item.form || {};
24
+ var nestedForm = formInfo.form || {};
25
+ var form_id = normalizeFormId((_ref = (_ref2 = (_nestedForm$id = nestedForm.id) !== null && _nestedForm$id !== void 0 ? _nestedForm$id : formInfo.form_id) !== null && _ref2 !== void 0 ? _ref2 : formInfo.id) !== null && _ref !== void 0 ? _ref : mapKey);
26
+ var shop_id = (_nestedForm$shop_id = nestedForm.shop_id) !== null && _nestedForm$shop_id !== void 0 ? _nestedForm$shop_id : formInfo.shop_id;
27
+ if (shop_id === undefined || shop_id === null || shop_id === '') {
28
+ return null;
29
+ }
30
+ return {
31
+ form_id: form_id,
32
+ shop_id: shop_id
33
+ };
20
34
  }
@@ -84,7 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
84
84
  enhancePayload?: SubmitPayloadEnhancer;
85
85
  }): Promise<T>;
86
86
  createOrder(params: CommitOrderParams['query']): {
87
- type: "virtual" | "appointment_booking";
87
+ type: "appointment_booking" | "virtual";
88
88
  platform: string;
89
89
  sales_channel: string;
90
90
  order_sales_channel: string;
@@ -869,6 +869,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
869
869
  }, {
870
870
  key: "createOrder",
871
871
  value: function createOrder(params) {
872
+ var _this2 = this;
872
873
  var order = _objectSpread({
873
874
  type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
874
875
  // 要从外面拿,virtual
@@ -886,6 +887,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
886
887
  var is_deposit = 0; // 是否存在定金,0 不存在,1 存在
887
888
  if (params.cartItems.length > 0) {
888
889
  params.cartItems.forEach(function (item) {
890
+ var _params$extraData;
889
891
  if (!item._origin.duration) {
890
892
  var _generateDuration = generateDuration(item),
891
893
  duration = _generateDuration.duration,
@@ -897,7 +899,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
897
899
  item._origin.product.discount_list = discountList;
898
900
 
899
901
  // 为预约补齐 holder 信息
900
- ensureCartItemOriginHolder(item);
902
+ if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
903
+ ensureCartItemOriginHolder(item, _this2.window);
904
+ }
901
905
 
902
906
  // 购物车是否为普通商品
903
907
  if (isNormalProduct(item._origin)) {
@@ -2,6 +2,7 @@ import Decimal from 'decimal.js';
2
2
  import { CartItem } from "../Cart";
3
3
  import type { ScanOrderSubmitPayload, ScanOrderSubmitProduct, ScanOrderSummary, ScanOrderTempOrder } from '../../solution/ScanOrder/types';
4
4
  import type { RulesParamsHooks } from '../Rules/types';
5
+ import type { WindowPlugin } from '../../plugins';
5
6
  /**
6
7
  * 把"含 option 的主商品单价"与 bundle 合成"单行 composite 单价"。
7
8
  *
@@ -94,7 +95,7 @@ export interface CartOrderHolder {
94
95
  /**
95
96
  * 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
96
97
  */
97
- export declare function ensureCartItemOriginHolder(cartItem: CartItem): void;
98
+ export declare function ensureCartItemOriginHolder(cartItem: CartItem, window?: WindowPlugin): void;
98
99
  export declare const getAllDiscountList: (cartItem: CartItem) => any;
99
100
  export declare function createUuidV4(): string;
100
101
  export declare function isTempOrder(data: any): data is ScanOrderTempOrder;
@@ -260,17 +260,21 @@ export var mergeRelationForms = function mergeRelationForms(relationForms) {
260
260
  return item.form_record_ids.length > 0;
261
261
  }); // 过滤掉没有有效记录的表单
262
262
  };
263
- function resolveCartItemHolderCustomerId(cartItem) {
264
- var _origin$metadata, _ref5, _origin$holder$custom, _origin$holder, _account$_origin;
265
- var origin = cartItem._origin;
266
- var account = origin === null || origin === void 0 || (_origin$metadata = origin.metadata) === null || _origin$metadata === void 0 ? void 0 : _origin$metadata.account;
267
- return (_ref5 = (_origin$holder$custom = origin === null || origin === void 0 || (_origin$holder = origin.holder) === null || _origin$holder === void 0 ? void 0 : _origin$holder.customer_id) !== null && _origin$holder$custom !== void 0 ? _origin$holder$custom : account === null || account === void 0 || (_account$_origin = account._origin) === null || _account$_origin === void 0 ? void 0 : _account$_origin.customer_id) !== null && _ref5 !== void 0 ? _ref5 : account === null || account === void 0 ? void 0 : account.customer_id;
263
+ function getCustomerIdFromStorage(window) {
264
+ try {
265
+ var _window$getLocalStora;
266
+ var customer = JSON.parse((window === null || window === void 0 || (_window$getLocalStora = window.getLocalStorage) === null || _window$getLocalStora === void 0 ? void 0 : _window$getLocalStora.call(window, 'customer')) || '{}');
267
+ var customerId = Number(customer === null || customer === void 0 ? void 0 : customer.id);
268
+ return Number.isFinite(customerId) && customerId > 0 ? customerId : undefined;
269
+ } catch (_unused) {
270
+ return undefined;
271
+ }
268
272
  }
269
273
 
270
274
  /**
271
275
  * 为购物车行补齐订单所需的 holder 信息(与 cartAccount 结构保持一致)
272
276
  */
273
- export function ensureCartItemOriginHolder(cartItem) {
277
+ export function ensureCartItemOriginHolder(cartItem, window) {
274
278
  var _cartItem$_origin, _cartItem$_productIni;
275
279
  if (cartItem !== null && cartItem !== void 0 && (_cartItem$_origin = cartItem._origin) !== null && _cartItem$_origin !== void 0 && _cartItem$_origin.holder) {
276
280
  return;
@@ -281,7 +285,7 @@ export function ensureCartItemOriginHolder(cartItem) {
281
285
  return;
282
286
  }
283
287
  cartItem._origin.holder = {
284
- customer_id: resolveCartItemHolderCustomerId(cartItem),
288
+ customer_id: getCustomerIdFromStorage(window),
285
289
  form_id: holderConfig.resource_id,
286
290
  form_record: [formRecordId]
287
291
  };
@@ -362,7 +366,7 @@ function toBundleCustomPriceString(value) {
362
366
  function formatSubmitBundleItems(bundle) {
363
367
  if (!Array.isArray(bundle)) return [];
364
368
  return bundle.map(function (b) {
365
- var _rawBundle$bundle_sel, _rawBundle$price_type, _rawBundle$surcharge_, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$extension_, _rawBundle$extension_2, _rawBundle$price_type2, _ref6, _rawBundle$custom_pri;
369
+ var _rawBundle$bundle_sel, _rawBundle$price_type, _rawBundle$surcharge_, _rawBundle$is_charge_, _rawBundle$bundle_var, _rawBundle$extension_, _rawBundle$extension_2, _rawBundle$price_type2, _ref5, _rawBundle$custom_pri;
366
370
  var rawBundle = b && _typeof(b) === 'object' ? b : {};
367
371
  var existedMetadata = rawBundle.metadata && _typeof(rawBundle.metadata) === 'object' ? rawBundle.metadata : {};
368
372
  var sellingPriceNum = toBundleNumber((_rawBundle$bundle_sel = rawBundle.bundle_selling_price) !== null && _rawBundle$bundle_sel !== void 0 ? _rawBundle$bundle_sel : rawBundle.price, 0);
@@ -386,7 +390,7 @@ function formatSubmitBundleItems(bundle) {
386
390
  price_type: priceType,
387
391
  price_type_ext: (_rawBundle$price_type2 = rawBundle.price_type_ext) !== null && _rawBundle$price_type2 !== void 0 ? _rawBundle$price_type2 : '',
388
392
  // custom_price: customPriceStr,
389
- custom_price_type: (_ref6 = (_rawBundle$custom_pri = rawBundle.custom_price_type) !== null && _rawBundle$custom_pri !== void 0 ? _rawBundle$custom_pri : priceType) !== null && _ref6 !== void 0 ? _ref6 : '',
393
+ custom_price_type: (_ref5 = (_rawBundle$custom_pri = rawBundle.custom_price_type) !== null && _rawBundle$custom_pri !== void 0 ? _rawBundle$custom_pri : priceType) !== null && _ref5 !== void 0 ? _ref5 : '',
390
394
  bundle_selling_price: sellingPriceNum,
391
395
  option: formatSubmitOptionItems(rawBundle.option),
392
396
  bundle_group_id: rawBundle === null || rawBundle === void 0 ? void 0 : rawBundle.group_id,
@@ -548,7 +552,7 @@ export function createDefaultTempOrder(params) {
548
552
  };
549
553
  }
550
554
  export function buildSubmitPayload(params) {
551
- var _ref7, _ref8, _ref9, _tempOrder$is_price_i, _tempOrder$is_deposit;
555
+ var _ref6, _ref7, _ref8, _tempOrder$is_price_i, _tempOrder$is_deposit;
552
556
  var tempOrder = params.tempOrder,
553
557
  cacheId = params.cacheId,
554
558
  _params$now = params.now,
@@ -596,10 +600,10 @@ export function buildSubmitPayload(params) {
596
600
  var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
597
601
  platform: normalizeSubmitPlatform(platform !== null && platform !== void 0 ? platform : tempOrder.platform),
598
602
  request_unique_idempotency_token: cacheId,
599
- type: (_ref7 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref7 !== void 0 ? _ref7 : 'table-order',
600
- business_code: (_ref8 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref8 !== void 0 ? _ref8 : 'table-order',
603
+ type: (_ref6 = type !== null && type !== void 0 ? type : tempOrder.type) !== null && _ref6 !== void 0 ? _ref6 : 'table-order',
604
+ business_code: (_ref7 = businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code) !== null && _ref7 !== void 0 ? _ref7 : 'table-order',
601
605
  sales_channel: tempOrder.sales_channel || 'my_pisel',
602
- order_sales_channel: (_ref9 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref9 !== void 0 ? _ref9 : 'online_store',
606
+ order_sales_channel: (_ref8 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref8 !== void 0 ? _ref8 : 'online_store',
603
607
  status: tempOrder.status || 'normal',
604
608
  payment_status: tempOrder.payment_status || 'payment_processing',
605
609
  // shipping_status: tempOrder.shipping_status || 'unfulfilled',
@@ -623,10 +627,10 @@ export function buildSubmitPayload(params) {
623
627
  // holder: tempOrder.holder || null,
624
628
  // summary,
625
629
  metadata: function () {
626
- var _ref10 = tempOrder.metadata || {},
627
- _collectPax = _ref10.collect_pax,
628
- _tableOccupancyDuration = _ref10.table_occupancy_duration,
629
- rest = _objectWithoutProperties(_ref10, _excluded3);
630
+ var _ref9 = tempOrder.metadata || {},
631
+ _collectPax = _ref9.collect_pax,
632
+ _tableOccupancyDuration = _ref9.table_occupancy_duration,
633
+ rest = _objectWithoutProperties(_ref9, _excluded3);
630
634
  return _objectSpread({}, rest);
631
635
  }(),
632
636
  products: (tempOrder.products || []).map(function (product) {
@@ -131,6 +131,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
131
131
  * 获取 holder 表单 map
132
132
  */
133
133
  getHolderFormMap(): import("../../modules").HolderFormMap;
134
+ /**
135
+ * 登录后或外部触发时,按当前 holderMap 批量刷新所有表单的 records
136
+ */
137
+ refreshAllHolderFormRecords(params?: {
138
+ customer_id?: number;
139
+ }): Promise<import("../../modules").HolderFormMap>;
134
140
  /**
135
141
  * 添加表单记录
136
142
  */
@@ -320,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
320
326
  date: string;
321
327
  status: string;
322
328
  week: string;
323
- weekNum: 0 | 1 | 2 | 3 | 4 | 5 | 6;
329
+ weekNum: 0 | 5 | 1 | 4 | 2 | 3 | 6;
324
330
  }[]>;
325
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
326
332
  private getScheduleDataByIds;
@@ -367,7 +373,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
367
373
  };
368
374
  setOtherData(key: string, value: any): void;
369
375
  getOtherData(key: string): any;
370
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
376
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
371
377
  /**
372
378
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
373
379
  *