@pisell/pisellos 2.2.173 → 2.2.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.
@@ -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";
@@ -687,7 +687,8 @@ export function buildSubmitPayload(params) {
687
687
  }
688
688
  }
689
689
  var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
690
- customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 0,
690
+ customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
691
+ customer_name: tempOrder.customer_name || 'Select a customer',
691
692
  order_number: null,
692
693
  shop_order_number: null,
693
694
  shop_full_order_number: null,
@@ -47,7 +47,6 @@ export declare class QuotationModule extends BaseModule implements Module {
47
47
  customer_id?: number | string;
48
48
  }): Map<string, string | null>;
49
49
  setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
50
- private filterQuotationsByCustomer;
51
50
  private isQuotationVisibleForCustomer;
52
51
  private hasValidCustomerId;
53
52
  private isQuotationActiveAt;
@@ -78,22 +78,21 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
78
78
  case 0:
79
79
  query = {};
80
80
  if (params !== null && params !== void 0 && params.channel) query.channel = params.channel;
81
- if (params !== null && params !== void 0 && params.customer_id) query.customer_id = String(params.customer_id);
82
81
  if ((params === null || params === void 0 ? void 0 : params.channel) === 'online_store') {
83
82
  query.channel = 'online-store';
84
83
  }
85
- _context2.next = 6;
84
+ _context2.next = 5;
86
85
  return this.request.get('/quotation/available', query, {
87
86
  useCache: false
88
87
  });
89
- case 6:
88
+ case 5:
90
89
  res = _context2.sent;
91
- list = this.filterQuotationsByCustomer((res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [], params === null || params === void 0 ? void 0 : params.customer_id);
90
+ list = (res === null || res === void 0 || (_data = res.data) === null || _data === void 0 ? void 0 : _data.list) || (res === null || res === void 0 ? void 0 : res.list) || [];
92
91
  list.sort(function (a, b) {
93
92
  return a.sort - b.sort;
94
93
  });
95
94
  this.store.list = list;
96
- case 10:
95
+ case 9:
97
96
  case "end":
98
97
  return _context2.stop();
99
98
  }
@@ -220,14 +219,6 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
220
219
  value: function setScheduleResolver(resolver) {
221
220
  this.scheduleResolver = resolver;
222
221
  }
223
- }, {
224
- key: "filterQuotationsByCustomer",
225
- value: function filterQuotationsByCustomer(list, customerId) {
226
- var _this2 = this;
227
- return list.filter(function (quotation) {
228
- return _this2.isQuotationVisibleForCustomer(quotation, customerId);
229
- });
230
- }
231
222
  }, {
232
223
  key: "isQuotationVisibleForCustomer",
233
224
  value: function isQuotationVisibleForCustomer(quotation, customerId) {
@@ -248,17 +239,17 @@ export var QuotationModule = /*#__PURE__*/function (_BaseModule) {
248
239
  key: "isQuotationActiveAt",
249
240
  value: function isQuotationActiveAt(quotation, datetime) {
250
241
  var _quotation$schedule,
251
- _this3 = this;
242
+ _this2 = this;
252
243
  if (!((_quotation$schedule = quotation.schedule) !== null && _quotation$schedule !== void 0 && _quotation$schedule.length)) return false;
253
244
  var scheduleItems = [];
254
245
  quotation.schedule.forEach(function (s) {
255
- var _this3$scheduleResolv;
256
- var full = (_this3$scheduleResolv = _this3.scheduleResolver) === null || _this3$scheduleResolv === void 0 ? void 0 : _this3$scheduleResolv.call(_this3, s.id);
246
+ var _this2$scheduleResolv;
247
+ var full = (_this2$scheduleResolv = _this2.scheduleResolver) === null || _this2$scheduleResolv === void 0 ? void 0 : _this2$scheduleResolv.call(_this2, s.id);
257
248
  if (full) {
258
249
  scheduleItems.push(full);
259
250
  return;
260
251
  }
261
- if (_this3.scheduleResolver) {
252
+ if (_this2.scheduleResolver) {
262
253
  return;
263
254
  }
264
255
  var fallbackSchedule = _objectSpread(_objectSpread({}, s), {}, {
@@ -21,7 +21,7 @@ export declare class ProductsModule extends BaseModule implements Module {
21
21
  private isPriceFormatterRegistered;
22
22
  private quotationPriceBridge?;
23
23
  private quotationBridgeChannel?;
24
- private quotationBridgeCustomerId?;
24
+ private quotationBridgeLoadedKey?;
25
25
  private quotationBridgeRefreshPromise?;
26
26
  private quotationBridgeRefreshKey?;
27
27
  private productDataSource;
@@ -73,7 +73,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
73
73
  // 普通层 QuotationModule 桥接器:本地计算报价单价格,替代 /product/query/price
74
74
  _defineProperty(_assertThisInitialized(_this), "quotationPriceBridge", void 0);
75
75
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeChannel", void 0);
76
- _defineProperty(_assertThisInitialized(_this), "quotationBridgeCustomerId", void 0);
76
+ _defineProperty(_assertThisInitialized(_this), "quotationBridgeLoadedKey", '');
77
77
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshPromise", void 0);
78
78
  _defineProperty(_assertThisInitialized(_this), "quotationBridgeRefreshKey", void 0);
79
79
  // ---- 商品数据同步相关 ----
@@ -354,7 +354,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
354
354
  value: (function () {
355
355
  var _refreshQuotationPriceBridge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
356
356
  var _this3 = this;
357
- var customerId, refreshKey;
357
+ var refreshKey;
358
358
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
359
359
  while (1) switch (_context4.prev = _context4.next) {
360
360
  case 0:
@@ -364,37 +364,35 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
364
364
  }
365
365
  return _context4.abrupt("return");
366
366
  case 2:
367
- customerId = params && 'customer_id' in params ? params.customer_id : this.quotationBridgeCustomerId;
368
- refreshKey = this.getQuotationBridgeScopeKey(customerId);
367
+ refreshKey = this.getQuotationBridgeScopeKey();
369
368
  if (!(this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey)) {
370
- _context4.next = 8;
369
+ _context4.next = 7;
371
370
  break;
372
371
  }
373
- _context4.next = 7;
372
+ _context4.next = 6;
374
373
  return this.quotationBridgeRefreshPromise;
375
- case 7:
374
+ case 6:
376
375
  return _context4.abrupt("return");
377
- case 8:
376
+ case 7:
378
377
  if (!this.quotationBridgeRefreshPromise) {
379
- _context4.next = 11;
378
+ _context4.next = 10;
380
379
  break;
381
380
  }
382
- _context4.next = 11;
381
+ _context4.next = 10;
383
382
  return this.quotationBridgeRefreshPromise;
384
- case 11:
383
+ case 10:
385
384
  this.quotationBridgeRefreshKey = refreshKey;
386
385
  this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
387
- channel: this.quotationBridgeChannel,
388
- customer_id: customerId
386
+ channel: this.quotationBridgeChannel
389
387
  }).then(function () {
390
- _this3.quotationBridgeCustomerId = customerId;
388
+ _this3.quotationBridgeLoadedKey = refreshKey;
391
389
  }).finally(function () {
392
390
  _this3.quotationBridgeRefreshPromise = undefined;
393
391
  _this3.quotationBridgeRefreshKey = undefined;
394
392
  });
395
- _context4.next = 15;
393
+ _context4.next = 14;
396
394
  return this.quotationBridgeRefreshPromise;
397
- case 15:
395
+ case 14:
398
396
  case "end":
399
397
  return _context4.stop();
400
398
  }
@@ -432,7 +430,7 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
432
430
  _context5.next = 7;
433
431
  return this.quotationBridgeRefreshPromise;
434
432
  case 7:
435
- if (!(this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId))) {
433
+ if (!(this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey)) {
436
434
  _context5.next = 10;
437
435
  break;
438
436
  }
@@ -453,8 +451,8 @@ export var ProductsModule = /*#__PURE__*/function (_BaseModule) {
453
451
  }()
454
452
  }, {
455
453
  key: "getQuotationBridgeScopeKey",
456
- value: function getQuotationBridgeScopeKey(customerId) {
457
- return "".concat(this.quotationBridgeChannel || '', ":").concat(customerId !== null && customerId !== void 0 ? customerId : '');
454
+ value: function getQuotationBridgeScopeKey() {
455
+ return this.quotationBridgeChannel || '';
458
456
  }
459
457
  }, {
460
458
  key: "buildPriceDataFromQuotation",
@@ -1771,10 +1771,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
1771
1771
  }, {
1772
1772
  key: "getWalletProductList",
1773
1773
  value: function getWalletProductList() {
1774
- var _this$store$order3, _tempOrder$products;
1774
+ var _this$store$order3, _tempOrder$products, _tempOrder$products2;
1775
1775
  var tempOrder = (_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 ? void 0 : _this$store$order3.getTempOrder();
1776
1776
  if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
1777
- return tempOrder.products.map(function (product) {
1777
+ // 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
1778
+ var products = tempOrder === null || tempOrder === void 0 || (_tempOrder$products2 = tempOrder.products) === null || _tempOrder$products2 === void 0 ? void 0 : _tempOrder$products2.filter(function (n) {
1779
+ return n.product_id;
1780
+ });
1781
+ return products.map(function (product) {
1778
1782
  var _product$product_vari, _product$is_charge_ta, _product$holder_id, _metadata$main_produc, _metadata$main_produc2;
1779
1783
  var metadata = product.metadata || {};
1780
1784
  return {
@@ -75,7 +75,7 @@ function findVariantById(origin, variantId) {
75
75
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
76
76
  */
77
77
  export function transformBaseProductToOrderProduct(params) {
78
- var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _payload$option, _payload$bundle, _payload$unique_ident, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref25, _ref26, _origin$base_price, _ref27, _ref28, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref29, _ref30, _payload$tax_fee, _ref31, _ref32, _payload$is_charge_ta;
78
+ var _ref10, _ref11, _ref12, _payload$product_id, _ref13, _ref14, _payload$product_vari, _payload$_origin, _payload$_origin2, _ref15, _findVariantById, _ref16, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _payload$price, _ref23, _payload$line_total, _payload$_extend, _ref24, _payload$option, _payload$bundle, _payload$quantity, _payload$_extend2, _extend, _extend2, _ref25, _ref26, _origin$base_price, _ref27, _ref28, _payload$line_total2, _payload$_extend3, _payload$_extend4, _extend3, _payload$_extend5, _payload$_extend6, _ref29, _ref30, _payload$tax_fee, _ref31, _ref32, _payload$is_charge_ta;
79
79
  var payload = params.payload,
80
80
  _params$fallbackProdu = params.fallbackProductId,
81
81
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
@@ -92,7 +92,9 @@ export function transformBaseProductToOrderProduct(params) {
92
92
  var hasPriceOverride = payload.price_override !== undefined && payload.price_override !== null && payload.price_override !== '';
93
93
  var productOptionItem = normalizeOptionItems((_ref24 = (_payload$option = payload.option) !== null && _payload$option !== void 0 ? _payload$option : payload.options) !== null && _ref24 !== void 0 ? _ref24 : payload.product_option_item);
94
94
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride);
95
- var uniqueIdentificationNumber = (_payload$unique_ident = payload.unique_identification_number) !== null && _payload$unique_ident !== void 0 ? _payload$unique_ident : payload.unique;
95
+ // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
96
+ // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
97
+ var uniqueIdentificationNumber = payload.unique_identification_number;
96
98
  var resolvedQuantity = toSafePositiveInt((_payload$quantity = payload.quantity) !== null && _payload$quantity !== void 0 ? _payload$quantity : payload.num, 1);
97
99
  var originTotal = resolveManualDiscountOriginTotal({
98
100
  originTotal: payload.origin_total,
@@ -615,7 +615,8 @@ function buildSubmitPayload(params) {
615
615
  }
616
616
  const payload = {
617
617
  ...tempOrderRest,
618
- customer_id: tempOrder.customer_id ?? 0,
618
+ customer_id: tempOrder.customer_id ?? 1,
619
+ customer_name: tempOrder.customer_name || "Select a customer",
619
620
  order_number: null,
620
621
  shop_order_number: null,
621
622
  shop_full_order_number: null,
@@ -47,7 +47,6 @@ export declare class QuotationModule extends BaseModule implements Module {
47
47
  customer_id?: number | string;
48
48
  }): Map<string, string | null>;
49
49
  setScheduleResolver(resolver: (id: number) => ScheduleItem | undefined): void;
50
- private filterQuotationsByCustomer;
51
50
  private isQuotationVisibleForCustomer;
52
51
  private hasValidCustomerId;
53
52
  private isQuotationActiveAt;
@@ -43,8 +43,6 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
43
43
  const query = {};
44
44
  if (params == null ? void 0 : params.channel)
45
45
  query.channel = params.channel;
46
- if (params == null ? void 0 : params.customer_id)
47
- query.customer_id = String(params.customer_id);
48
46
  if ((params == null ? void 0 : params.channel) === "online_store") {
49
47
  query.channel = "online-store";
50
48
  }
@@ -53,10 +51,7 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
53
51
  query,
54
52
  { useCache: false }
55
53
  );
56
- const list = this.filterQuotationsByCustomer(
57
- ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [],
58
- params == null ? void 0 : params.customer_id
59
- );
54
+ const list = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.list) || (res == null ? void 0 : res.list) || [];
60
55
  list.sort((a, b) => a.sort - b.sort);
61
56
  this.store.list = list;
62
57
  }
@@ -130,9 +125,6 @@ var QuotationModule = class extends import_BaseModule.BaseModule {
130
125
  setScheduleResolver(resolver) {
131
126
  this.scheduleResolver = resolver;
132
127
  }
133
- filterQuotationsByCustomer(list, customerId) {
134
- return list.filter((quotation) => this.isQuotationVisibleForCustomer(quotation, customerId));
135
- }
136
128
  isQuotationVisibleForCustomer(quotation, customerId) {
137
129
  const customers = quotation.customer || [];
138
130
  if (customers.length === 0)
@@ -21,7 +21,7 @@ export declare class ProductsModule extends BaseModule implements Module {
21
21
  private isPriceFormatterRegistered;
22
22
  private quotationPriceBridge?;
23
23
  private quotationBridgeChannel?;
24
- private quotationBridgeCustomerId?;
24
+ private quotationBridgeLoadedKey?;
25
25
  private quotationBridgeRefreshPromise?;
26
26
  private quotationBridgeRefreshKey?;
27
27
  private productDataSource;
@@ -44,6 +44,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
44
44
  this.formatters = [];
45
45
  // 是否已注册内置价格格式化器
46
46
  this.isPriceFormatterRegistered = false;
47
+ this.quotationBridgeLoadedKey = "";
47
48
  this.pendingSyncMessages = [];
48
49
  }
49
50
  async initialize(core, options) {
@@ -220,8 +221,7 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
220
221
  async refreshQuotationPriceBridge(params) {
221
222
  if (!this.quotationPriceBridge)
222
223
  return;
223
- const customerId = params && "customer_id" in params ? params.customer_id : this.quotationBridgeCustomerId;
224
- const refreshKey = this.getQuotationBridgeScopeKey(customerId);
224
+ const refreshKey = this.getQuotationBridgeScopeKey();
225
225
  if (this.quotationBridgeRefreshPromise && this.quotationBridgeRefreshKey === refreshKey) {
226
226
  await this.quotationBridgeRefreshPromise;
227
227
  return;
@@ -231,10 +231,9 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
231
231
  }
232
232
  this.quotationBridgeRefreshKey = refreshKey;
233
233
  this.quotationBridgeRefreshPromise = this.quotationPriceBridge.loadQuotations({
234
- channel: this.quotationBridgeChannel,
235
- customer_id: customerId
234
+ channel: this.quotationBridgeChannel
236
235
  }).then(() => {
237
- this.quotationBridgeCustomerId = customerId;
236
+ this.quotationBridgeLoadedKey = refreshKey;
238
237
  }).finally(() => {
239
238
  this.quotationBridgeRefreshPromise = void 0;
240
239
  this.quotationBridgeRefreshKey = void 0;
@@ -253,12 +252,12 @@ var ProductsModule = class extends import_BaseModule.BaseModule {
253
252
  if (this.quotationBridgeRefreshPromise) {
254
253
  await this.quotationBridgeRefreshPromise;
255
254
  }
256
- if (this.getQuotationBridgeScopeKey(customerId) !== this.getQuotationBridgeScopeKey(this.quotationBridgeCustomerId)) {
255
+ if (this.getQuotationBridgeScopeKey() !== this.quotationBridgeLoadedKey) {
257
256
  await this.refreshQuotationPriceBridge({ customer_id: customerId });
258
257
  }
259
258
  }
260
- getQuotationBridgeScopeKey(customerId) {
261
- return `${this.quotationBridgeChannel || ""}:${customerId ?? ""}`;
259
+ getQuotationBridgeScopeKey() {
260
+ return this.quotationBridgeChannel || "";
262
261
  }
263
262
  buildPriceDataFromQuotation(product, datetime, customerId) {
264
263
  var _a;
@@ -1035,11 +1035,12 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
1035
1035
  return this.store.order.updateVoucherOrderPayments(payments);
1036
1036
  }
1037
1037
  getWalletProductList() {
1038
- var _a, _b;
1038
+ var _a, _b, _c;
1039
1039
  const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
1040
1040
  if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
1041
1041
  return [];
1042
- return tempOrder.products.map((product) => {
1042
+ const products = (_c = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _c.filter((n) => n.product_id);
1043
+ return products.map((product) => {
1043
1044
  const metadata = product.metadata || {};
1044
1045
  return {
1045
1046
  product_id: product.product_id,
@@ -124,7 +124,7 @@ function transformBaseProductToOrderProduct(params) {
124
124
  payload.bundle ?? payload.product_bundle,
125
125
  hasPriceOverride
126
126
  );
127
- const uniqueIdentificationNumber = payload.unique_identification_number ?? payload.unique;
127
+ const uniqueIdentificationNumber = payload.unique_identification_number;
128
128
  const resolvedQuantity = toSafePositiveInt(payload.quantity ?? payload.num, 1);
129
129
  const originTotal = (0, import_manualProductDiscount.resolveManualDiscountOriginTotal)({
130
130
  originTotal: payload.origin_total,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.173",
4
+ "version": "2.2.174",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",