@pisell/pisellos 2.1.173 → 2.1.174

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 (93) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  3. package/dist/model/strategy/adapter/walletPass/evaluator.js +4 -2
  4. package/dist/modules/Discount/availability.d.ts +7 -0
  5. package/dist/modules/Discount/availability.js +52 -0
  6. package/dist/modules/Discount/entitlementPass.d.ts +34 -0
  7. package/dist/modules/Discount/entitlementPass.js +147 -0
  8. package/dist/modules/Discount/entitlementState.d.ts +8 -0
  9. package/dist/modules/Discount/entitlementState.js +205 -0
  10. package/dist/modules/Discount/index.d.ts +6 -3
  11. package/dist/modules/Discount/index.js +125 -23
  12. package/dist/modules/Discount/types.d.ts +34 -5
  13. package/dist/modules/Holder/index.d.ts +48 -0
  14. package/dist/modules/Holder/index.js +640 -0
  15. package/dist/modules/Holder/types.d.ts +123 -0
  16. package/dist/modules/Holder/types.js +1 -0
  17. package/dist/modules/Holder/utils.d.ts +13 -0
  18. package/dist/modules/Holder/utils.js +34 -0
  19. package/dist/modules/Order/index.d.ts +1 -0
  20. package/dist/modules/Order/index.js +18 -1
  21. package/dist/modules/Order/types.d.ts +2 -0
  22. package/dist/modules/Order/utils.d.ts +10 -0
  23. package/dist/modules/Order/utils.js +35 -3
  24. package/dist/modules/Product/types.d.ts +7 -0
  25. package/dist/modules/Rules/entitlementLines.d.ts +8 -0
  26. package/dist/modules/Rules/entitlementLines.js +157 -0
  27. package/dist/modules/Rules/index.d.ts +12 -2
  28. package/dist/modules/Rules/index.js +377 -112
  29. package/dist/modules/Rules/types.d.ts +2 -2
  30. package/dist/modules/index.d.ts +1 -0
  31. package/dist/modules/index.js +2 -1
  32. package/dist/plugins/window.d.ts +3 -0
  33. package/dist/solution/BookingByStep/index.d.ts +17 -2
  34. package/dist/solution/BookingByStep/index.js +276 -204
  35. package/dist/solution/BookingByStep/types.d.ts +2 -1
  36. package/dist/solution/BookingByStep/types.js +3 -1
  37. package/dist/solution/ScanOrder/index.js +1 -1
  38. package/dist/solution/ScanOrder/types.d.ts +1 -0
  39. package/dist/solution/ShopDiscount/index.d.ts +3 -0
  40. package/dist/solution/ShopDiscount/index.js +161 -78
  41. package/dist/solution/ShopDiscount/utils.d.ts +1 -0
  42. package/dist/solution/ShopDiscount/utils.js +40 -1
  43. package/dist/solution/VenueBooking/index.d.ts +19 -0
  44. package/dist/solution/VenueBooking/index.js +978 -748
  45. package/dist/solution/VenueBooking/types.d.ts +2 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  48. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +2 -0
  49. package/lib/model/strategy/adapter/walletPass/evaluator.js +4 -2
  50. package/lib/modules/Discount/availability.d.ts +7 -0
  51. package/lib/modules/Discount/availability.js +91 -0
  52. package/lib/modules/Discount/entitlementPass.d.ts +34 -0
  53. package/lib/modules/Discount/entitlementPass.js +184 -0
  54. package/lib/modules/Discount/entitlementState.d.ts +8 -0
  55. package/lib/modules/Discount/entitlementState.js +206 -0
  56. package/lib/modules/Discount/index.d.ts +6 -3
  57. package/lib/modules/Discount/index.js +66 -16
  58. package/lib/modules/Discount/types.d.ts +34 -5
  59. package/lib/modules/Holder/index.d.ts +48 -0
  60. package/lib/modules/Holder/index.js +402 -0
  61. package/lib/modules/Holder/types.d.ts +123 -0
  62. package/lib/modules/Holder/types.js +17 -0
  63. package/lib/modules/Holder/utils.d.ts +13 -0
  64. package/lib/modules/Holder/utils.js +71 -0
  65. package/lib/modules/Order/index.d.ts +1 -0
  66. package/lib/modules/Order/index.js +14 -0
  67. package/lib/modules/Order/types.d.ts +2 -0
  68. package/lib/modules/Order/utils.d.ts +10 -0
  69. package/lib/modules/Order/utils.js +36 -5
  70. package/lib/modules/Product/types.d.ts +7 -0
  71. package/lib/modules/Rules/entitlementLines.d.ts +8 -0
  72. package/lib/modules/Rules/entitlementLines.js +158 -0
  73. package/lib/modules/Rules/index.d.ts +12 -2
  74. package/lib/modules/Rules/index.js +304 -70
  75. package/lib/modules/Rules/types.d.ts +2 -2
  76. package/lib/modules/index.d.ts +1 -0
  77. package/lib/modules/index.js +3 -1
  78. package/lib/plugins/window.d.ts +3 -0
  79. package/lib/solution/BookingByStep/index.d.ts +17 -2
  80. package/lib/solution/BookingByStep/index.js +39 -0
  81. package/lib/solution/BookingByStep/types.d.ts +2 -1
  82. package/lib/solution/BookingByStep/types.js +5 -0
  83. package/lib/solution/ScanOrder/index.js +1 -1
  84. package/lib/solution/ScanOrder/types.d.ts +1 -0
  85. package/lib/solution/ShopDiscount/index.d.ts +3 -0
  86. package/lib/solution/ShopDiscount/index.js +78 -28
  87. package/lib/solution/ShopDiscount/utils.d.ts +1 -0
  88. package/lib/solution/ShopDiscount/utils.js +42 -1
  89. package/lib/solution/VenueBooking/index.d.ts +19 -0
  90. package/lib/solution/VenueBooking/index.js +134 -16
  91. package/lib/solution/VenueBooking/types.d.ts +2 -0
  92. package/lib/types/index.d.ts +1 -0
  93. package/package.json +1 -1
@@ -1,4 +1,8 @@
1
1
  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); }
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 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; }
3
7
  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; }
4
8
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -27,6 +31,8 @@ import { uniqueById } from "../../solution/ShopDiscount/utils";
27
31
  import { BaseModule } from "../BaseModule";
28
32
  import { DiscountHooks } from "./types";
29
33
  import Decimal from 'decimal.js';
34
+ import { isEntitlementPass } from "./entitlementPass";
35
+ import { getDiscountLifecycleReason, getDiscountUsageLimitFailKey } from "./availability";
30
36
  export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
31
37
  _inherits(DiscountModule, _BaseModule);
32
38
  var _super = _createSuper(DiscountModule);
@@ -153,8 +159,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
153
159
  key: "loadPrepareConfig",
154
160
  value: function () {
155
161
  var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
156
- var _prepareConfig$data, _prepareConfig$data2;
157
- var prepareConfig, goodPassList;
162
+ var _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
163
+ var prepareConfig, _prepareConfig$data, _prepareConfig$data2, entitlementPassList, ids, rawDiscountList, goodPassList;
158
164
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
159
165
  while (1) switch (_context4.prev = _context4.next) {
160
166
  case 0:
@@ -162,9 +168,29 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
162
168
  return this.request.post("/order/prepare/config", params);
163
169
  case 2:
164
170
  prepareConfig = _context4.sent;
165
- goodPassList = this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || []))) || []; // this.setDiscountList(goodPassList);
166
- return _context4.abrupt("return", goodPassList);
171
+ if (params.with_entitlement_pass) {
172
+ _context4.next = 5;
173
+ break;
174
+ }
175
+ return _context4.abrupt("return", this.filterEnabledDiscountList([].concat(_toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data = prepareConfig.data) === null || _prepareConfig$data === void 0 ? void 0 : _prepareConfig$data.good_pass_list) || []), _toConsumableArray((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data2 = prepareConfig.data) === null || _prepareConfig$data2 === void 0 ? void 0 : _prepareConfig$data2.discount_card_list) || [])).filter(function (item) {
176
+ return !isEntitlementPass(item);
177
+ })));
167
178
  case 5:
179
+ entitlementPassList = (prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data3 = prepareConfig.data) === null || _prepareConfig$data3 === void 0 ? void 0 : _prepareConfig$data3.entitlement_pass_list) || [];
180
+ ids = new Set(entitlementPassList.map(function (item) {
181
+ return String(item.id);
182
+ }));
183
+ rawDiscountList = [].concat(_toConsumableArray(entitlementPassList), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data4 = prepareConfig.data) === null || _prepareConfig$data4 === void 0 ? void 0 : _prepareConfig$data4.good_pass_list) || []).filter(function (item) {
184
+ return !ids.has(String(item.id));
185
+ })), _toConsumableArray(((prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data5 = prepareConfig.data) === null || _prepareConfig$data5 === void 0 ? void 0 : _prepareConfig$data5.discount_card_list) || []).filter(function (item) {
186
+ return !ids.has(String(item.id));
187
+ })));
188
+ _context4.next = 10;
189
+ return this.setOriginalDiscountList(rawDiscountList);
190
+ case 10:
191
+ goodPassList = this.filterEnabledDiscountList(rawDiscountList); // this.setDiscountList(goodPassList);
192
+ return _context4.abrupt("return", goodPassList);
193
+ case 12:
168
194
  case "end":
169
195
  return _context4.stop();
170
196
  }
@@ -178,18 +204,22 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
178
204
  }, {
179
205
  key: "batchSearch",
180
206
  value: function () {
181
- var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, options) {
182
- var _ref, customerId, orderId, result, resultDiscountWithReason;
207
+ var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerIdOrOptions) {
208
+ var _this2 = this,
209
+ _entitlement$value,
210
+ _legacy$value;
211
+ var _ref, customerId, orderId, withEntitlementPass, params, _result, search, _yield$Promise$all, _yield$Promise$all2, legacy, entitlement, entitlementList, legacyList, ids, result;
183
212
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
184
213
  while (1) switch (_context5.prev = _context5.next) {
185
214
  case 0:
186
- _ref = options || {}, customerId = _ref.customerId, orderId = _ref.orderId;
187
- _context5.next = 3;
188
- return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({
215
+ _ref = typeof customerIdOrOptions === 'number' ? {
216
+ customerId: customerIdOrOptions,
217
+ orderId: undefined,
218
+ withEntitlementPass: false
219
+ } : customerIdOrOptions || {}, customerId = _ref.customerId, orderId = _ref.orderId, withEntitlementPass = _ref.withEntitlementPass;
220
+ params = _objectSpread(_objectSpread({
189
221
  code: code,
190
222
  translate_flag: 1,
191
- tags: ['good_pass', 'product_discount_card'],
192
- // available: 1,
193
223
  relation_product: 1,
194
224
  with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
195
225
  order_behavior_count: 1,
@@ -199,12 +229,75 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
199
229
  } : {}), {}, {
200
230
  unified_status_info_flag: 1,
201
231
  request_timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
232
+ });
233
+ if (withEntitlementPass) {
234
+ _context5.next = 7;
235
+ break;
236
+ }
237
+ _context5.next = 5;
238
+ return this.request.get("/machinecode/batch-search", _objectSpread(_objectSpread({}, params), {}, {
239
+ tags: ['good_pass', 'product_discount_card']
202
240
  }));
203
- case 3:
204
- result = _context5.sent;
205
- resultDiscountWithReason = this.filterEnabledDiscountListWithReason((result === null || result === void 0 ? void 0 : result.data) || []) || [];
206
- return _context5.abrupt("return", resultDiscountWithReason);
207
- case 6:
241
+ case 5:
242
+ _result = _context5.sent;
243
+ return _context5.abrupt("return", this.filterEnabledDiscountListWithReason(((_result === null || _result === void 0 ? void 0 : _result.data) || []).filter(function (item) {
244
+ return !isEntitlementPass(item);
245
+ })));
246
+ case 7:
247
+ // 旧券沿用统一状态校验;多次卡单独查询,保留暂不可用的卡供展示。
248
+ search = function search(query) {
249
+ return _this2.request.get("/machinecode/batch-search", query).then(function (value) {
250
+ return {
251
+ status: 'fulfilled',
252
+ value: value
253
+ };
254
+ }, function (reason) {
255
+ return {
256
+ status: 'rejected',
257
+ reason: reason
258
+ };
259
+ });
260
+ };
261
+ _context5.next = 10;
262
+ return Promise.all([search(_objectSpread(_objectSpread({}, params), {}, {
263
+ tags: ['good_pass', 'product_discount_card']
264
+ })), search(_objectSpread(_objectSpread({}, params), {}, {
265
+ tags: ['entitlement_pass'],
266
+ with_franchisor_data: 1,
267
+ unified_status_info_flag: 1,
268
+ with: [].concat(_toConsumableArray(params.with), ['franchiseeWalletPass:shop_id,source_shop_id,product_id,use'])
269
+ }))]);
270
+ case 10:
271
+ _yield$Promise$all = _context5.sent;
272
+ _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
273
+ legacy = _yield$Promise$all2[0];
274
+ entitlement = _yield$Promise$all2[1];
275
+ entitlementList = (entitlement.status === 'fulfilled' ? ((_entitlement$value = entitlement.value) === null || _entitlement$value === void 0 ? void 0 : _entitlement$value.data) || [] : []).filter(isEntitlementPass);
276
+ legacyList = legacy.status === 'fulfilled' ? ((_legacy$value = legacy.value) === null || _legacy$value === void 0 ? void 0 : _legacy$value.data) || [] : [];
277
+ ids = new Set(entitlementList.map(function (item) {
278
+ return String(item.id);
279
+ }));
280
+ result = this.filterEnabledDiscountListWithReason([].concat(_toConsumableArray(entitlementList), _toConsumableArray(legacyList.filter(function (item) {
281
+ return !isEntitlementPass(item) && !ids.has(String(item.id));
282
+ })))); // 任一类型查到可用卡即可继续,另一类型的查询失败不阻断该卡。
283
+ if (result.discountList.length) {
284
+ _context5.next = 23;
285
+ break;
286
+ }
287
+ if (!(legacy.status === 'rejected')) {
288
+ _context5.next = 21;
289
+ break;
290
+ }
291
+ throw legacy.reason;
292
+ case 21:
293
+ if (!(entitlement.status === 'rejected')) {
294
+ _context5.next = 23;
295
+ break;
296
+ }
297
+ throw entitlement.reason;
298
+ case 23:
299
+ return _context5.abrupt("return", result);
300
+ case 24:
208
301
  case "end":
209
302
  return _context5.stop();
210
303
  }
@@ -247,9 +340,9 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
247
340
  }, {
248
341
  key: "filterEnabledDiscountList",
249
342
  value: function filterEnabledDiscountList(discountList) {
250
- var _this2 = this;
343
+ var _this3 = this;
251
344
  return discountList.filter(function (discount) {
252
- return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
345
+ return isEntitlementPass(discount) ? !getDiscountLifecycleReason(discount) : discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this3.checkUsageCreditsLimit(discount);
253
346
  });
254
347
  }
255
348
 
@@ -316,14 +409,19 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
316
409
  }, {
317
410
  key: "filterEnabledDiscountListWithReason",
318
411
  value: function filterEnabledDiscountListWithReason(discountList) {
319
- var _this3 = this;
320
- var lists = discountList.filter(function (discount) {
412
+ var _this4 = this;
413
+ var entitlementPasses = discountList.filter(function (item) {
414
+ return isEntitlementPass(item) && !getDiscountLifecycleReason(item);
415
+ });
416
+ var lists = discountList.filter(function (item) {
417
+ return !isEntitlementPass(item);
418
+ }).filter(function (discount) {
321
419
  return discount.limit_status === 'enable';
322
420
  }).filter(function (discount) {
323
421
  var remaining = new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
324
422
  return remaining;
325
423
  }).map(function (discount) {
326
- var limitFailKey = _this3.checkUsageCreditsLimitWithFailKey(discount);
424
+ var limitFailKey = _this4.checkUsageCreditsLimitWithFailKey(discount);
327
425
  return _objectSpread(_objectSpread({}, discount), {}, {
328
426
  usageLimitFailKey: limitFailKey
329
427
  });
@@ -338,8 +436,12 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
338
436
  return item.usageLimitFailKey;
339
437
  });
340
438
  return {
341
- discountList: availableLists,
342
- unavailableReasonKey: currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey
439
+ discountList: [].concat(_toConsumableArray(entitlementPasses.map(function (item) {
440
+ return _objectSpread(_objectSpread({}, item), {}, {
441
+ usageLimitFailKey: getDiscountUsageLimitFailKey(item)
442
+ });
443
+ })), _toConsumableArray(availableLists)),
444
+ unavailableReasonKey: (currentFailDiscount === null || currentFailDiscount === void 0 ? void 0 : currentFailDiscount.usageLimitFailKey) || discountList.filter(isEntitlementPass).map(getDiscountLifecycleReason).find(Boolean) || null
343
445
  };
344
446
  }
345
447
 
@@ -45,6 +45,8 @@ interface ApplicableProductDetails {
45
45
  num: number;
46
46
  metadata?: {
47
47
  product_discount_difference?: number;
48
+ num?: number;
49
+ custom_product_bundle_map_id?: string;
48
50
  };
49
51
  discount?: {
50
52
  fixed_amount?: number;
@@ -63,10 +65,17 @@ interface UsageCreditsValue {
63
65
  max_per_week: number;
64
66
  max_per_month: number;
65
67
  }
68
+ export type IncludedUses = {
69
+ type: 'limited';
70
+ value: number;
71
+ } | {
72
+ type: 'unlimited';
73
+ value: null;
74
+ };
66
75
  export type DiscountFilterRejectKey = 'total_credits' | 'per_user_limit' | 'max_per_day' | 'max_per_week' | 'max_per_month';
67
76
  export interface DiscountWithReason {
68
77
  discountList: Discount[];
69
- unavailableReasonKey: DiscountFilterRejectKey | null;
78
+ unavailableReasonKey: DiscountFilterRejectKey | string | null;
70
79
  }
71
80
  interface ExtensionData {
72
81
  id: number;
@@ -93,19 +102,39 @@ export interface Discount {
93
102
  used_par_value: string;
94
103
  limit_status: string;
95
104
  limited_relation_product_data: Limitedrelationproductdata;
96
- balance: string;
105
+ balance?: string | number | null;
97
106
  format_title: Formattitle;
98
107
  metadata?: {
99
108
  discount_card_type?: 'fixed_amount' | 'percent';
100
109
  custom_product_bundle_map_id?: string;
101
110
  validity_type?: "custom_schedule_validity" | "fixed_validity";
102
- discount_calculation_mode: 'item_level' | 'order_level';
103
- holder: {
111
+ included_uses?: IncludedUses;
112
+ discount_calculation_mode?: 'item_level' | 'order_level';
113
+ holder?: {
104
114
  type: "customer" | "custom";
105
115
  };
106
116
  };
107
117
  product: Product;
108
- type: "product" | 'good_pass';
118
+ type?: 'product' | 'good_pass' | 'entitlement_pass' | 'discount_card' | 'product_discount_card';
119
+ shop_id?: number;
120
+ customer_id?: number | string | null;
121
+ holder?: {
122
+ holder_type?: string;
123
+ holder_id?: number | string | Array<number | string>;
124
+ [key: string]: any;
125
+ };
126
+ config?: {
127
+ isAvailable?: boolean;
128
+ maxUsagePerOrder?: number;
129
+ [key: string]: any;
130
+ };
131
+ reason?: string;
132
+ reasonCode?: string;
133
+ is_franchisor_pass?: number;
134
+ franchisee_wallet_pass?: {
135
+ use?: string;
136
+ };
137
+ committedAppliedProductDetails?: ApplicableProductDetails[];
109
138
  resource_id?: number;
110
139
  savedAmount?: number;
111
140
  isEditMode?: boolean;
@@ -0,0 +1,48 @@
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { IFormInfo, IFormRecord, IFormItemData, IFetchFormInfoParams, IFetchFormRecordsParams, IAddFormRecordParams, IAppendFormRecordParams, IEnsureFormDataParams, IEnsureFormByProductParams, IRefreshAllFormRecordsParams, HolderModuleAPI, HolderFormMap } from './types';
4
+ export * from './types';
5
+ export * from './utils';
6
+ export declare class HolderModule extends BaseModule implements Module, HolderModuleAPI {
7
+ protected defaultName: string;
8
+ protected defaultVersion: string;
9
+ private store;
10
+ private request;
11
+ private cacheId;
12
+ private openCache;
13
+ private fatherModule;
14
+ private isLoading;
15
+ private error;
16
+ /** 已加载过表单数据的 form_id 缓存标记 */
17
+ private loadedFormIds;
18
+ private window;
19
+ constructor(name?: string, version?: string);
20
+ initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
21
+ /** 统一提交 formMap,仅此处触发 store changed */
22
+ private commitFormMap;
23
+ /** 通知 UI 刷新(数据未变但需要 re-read 的场景) */
24
+ private notifyFormMapChanged;
25
+ getHolderFormMap(): HolderFormMap;
26
+ getHolderFormData(formId: number | string): IFormItemData | undefined;
27
+ setFormData(formId: number | string, data: Partial<IFormItemData>): void;
28
+ private ensureFormItem;
29
+ private hasFormData;
30
+ private patchFormMap;
31
+ fetchFormInfo(params: IFetchFormInfoParams): Promise<IFormInfo | IFormInfo[]>;
32
+ fetchRecords(params: IFetchFormRecordsParams): Promise<any>;
33
+ ensureFormData(params: IEnsureFormDataParams): Promise<IFormItemData>;
34
+ ensureFormByProduct(params: IEnsureFormByProductParams): Promise<IFormItemData | null>;
35
+ addFormRecord(params: IAddFormRecordParams): Promise<any>;
36
+ /**
37
+ * UI 层自行请求添加接口后,将返回记录合并到 holderMap 对应 form_id 的 records 中
38
+ */
39
+ appendFormRecord(params: IAppendFormRecordParams): IFormRecord;
40
+ removeFormRecord(formId: number | string, formRecordId: number): void;
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>;
47
+ storeChange(path?: string): void;
48
+ }