@pisell/pisellos 0.0.523 → 0.0.525

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.
@@ -50,7 +50,15 @@ function formatReason(template, value) {
50
50
  var c = currency === undefined || currency === null ? '' : String(currency);
51
51
  // 注意:必须先替换 value,再替换 currency
52
52
  // 否则 currency 注入的 "$" 会被后续的 /\$\{value\}/ 正则误吞
53
- return template.replace(/\$\{value\}/g, v).replace(/\{value\}/g, v).replace(/\{currency\}/g, c);
53
+ // 使用函数作为替换参数,避免替换串中的 "$" 被 String.prototype.replace
54
+ // 当作特殊序列(如 $$ -> $、$& 等)处理
55
+ return template.replace(/\$\{value\}/g, function () {
56
+ return v;
57
+ }).replace(/\{value\}/g, function () {
58
+ return v;
59
+ }).replace(/\{currency\}/g, function () {
60
+ return c;
61
+ });
54
62
  }
55
63
 
56
64
  /**
@@ -249,6 +257,7 @@ export var WalletPassEvaluator = /*#__PURE__*/function () {
249
257
  var rawText = this.getText(reasonCode);
250
258
  // 金额类型字段:从 otherParams.getData 取货币符号;非金额或取不到则留空
251
259
  var currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams$get = (_this$otherParams2 = _this$otherParams).getData) === null || _this$otherParams$get === void 0 ? void 0 : _this$otherParams$get.call(_this$otherParams2, 'shop_symbol')) || '' : '';
260
+ console.log(currency, 'currency12345');
252
261
  var reason = thresholdValue !== undefined ? formatReason(rawText, thresholdValue, currency) : rawText;
253
262
  results.push({
254
263
  voucher: voucher,
@@ -82,7 +82,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
82
82
  enhancePayload?: SubmitPayloadEnhancer;
83
83
  }): Promise<T>;
84
84
  createOrder(params: CommitOrderParams['query']): {
85
- type: "virtual" | "appointment_booking";
85
+ type: "appointment_booking" | "virtual";
86
86
  platform: string;
87
87
  sales_channel: string;
88
88
  order_sales_channel: string;
@@ -706,25 +706,50 @@ var getBundleItemIsDiscountPrice = function getBundleItemIsDiscountPrice(item) {
706
706
  var getBundleItemIsMarkupOrDiscountPrice = function getBundleItemIsMarkupOrDiscountPrice(item) {
707
707
  return getBundleItemIsMarkupPrice(item) || getBundleItemIsDiscountPrice(item);
708
708
  };
709
+ var getDiscountAmount = function getDiscountAmount(discounts) {
710
+ return (discounts || []).reduce(function (total, discount) {
711
+ return total.add(new Decimal(discount.amount || 0));
712
+ }, new Decimal(0)).toNumber();
713
+ };
709
714
 
710
715
  /**
711
716
  * 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
712
717
  */
713
718
  var getMainProductTotal = function getMainProductTotal(item) {
714
- var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$metadata2;
719
+ var _ref8, _ref9, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
715
720
  // 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
716
721
  // 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
717
722
  // 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
718
723
  var total = new Decimal((_ref8 = (_ref9 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref9 !== void 0 ? _ref9 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref8 !== void 0 ? _ref8 : 0);
724
+
725
+ // 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
726
+ var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
727
+ if (!hasMainProductPrice) {
728
+ var _ref10, _ref11, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
729
+ total = new Decimal((_ref10 = (_ref11 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref11 !== void 0 ? _ref11 : item.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
730
+ var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
731
+ var _item$metadata6;
732
+ return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
733
+ })) || [];
734
+ var mainProductDiscountAmount = getDiscountAmount(discount);
735
+ total = total.minus(mainProductDiscountAmount);
736
+
737
+ // 单规格
738
+ if (item !== null && item !== void 0 && item.option && Array.isArray(item === null || item === void 0 ? void 0 : item.option)) {
739
+ total = total.add(item === null || item === void 0 ? void 0 : item.option.reduce(function (t, option) {
740
+ return t.add(new Decimal(option.price || 0).mul(option.num || 1));
741
+ }, new Decimal(0)));
742
+ }
743
+ }
719
744
  var _iterator4 = _createForOfIteratorHelper((item === null || item === void 0 ? void 0 : item.bundle) || []),
720
745
  _step4;
721
746
  try {
722
747
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
723
748
  var bundleItem = _step4.value;
724
749
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
725
- var _ref10, _bundleItem$bundle_se2;
750
+ var _ref12, _bundleItem$bundle_se2;
726
751
  // IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
727
- var bundleItemTotal = new Decimal((_ref10 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref10 !== void 0 ? _ref10 : 0);
752
+ var bundleItemTotal = new Decimal((_ref12 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref12 !== void 0 ? _ref12 : 0);
728
753
  total = total.add(bundleItemTotal);
729
754
  }
730
755
  }
@@ -844,12 +869,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
844
869
  * @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
845
870
  * @returns 附加费列表(仅返回金额 > 0 的项)
846
871
  */
847
- export var getSurcharge = function getSurcharge(_ref11, options) {
872
+ export var getSurcharge = function getSurcharge(_ref13, options) {
848
873
  var _service$filter;
849
- var service = _ref11.service,
850
- addons = _ref11.addons,
851
- bookingDetail = _ref11.bookingDetail,
852
- bookingId = _ref11.bookingId;
874
+ var service = _ref13.service,
875
+ addons = _ref13.addons,
876
+ bookingDetail = _ref13.bookingDetail,
877
+ bookingId = _ref13.bookingId;
853
878
  var isEdit = options.isEdit,
854
879
  isInScheduleByDate = options.isInScheduleByDate,
855
880
  surcharge_list = options.surcharge_list,
@@ -971,11 +996,11 @@ export var getSurcharge = function getSurcharge(_ref11, options) {
971
996
  scheduleById: scheduleById || {},
972
997
  isInScheduleByDate: isInScheduleByDate
973
998
  })) {
974
- var _ref12, _bundleItem$bundle_se3;
999
+ var _ref14, _bundleItem$bundle_se3;
975
1000
  var _mainQuantity = item.num || 1;
976
1001
  matchedItems.push({
977
1002
  isMain: false,
978
- total: Number((_ref12 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref12 !== void 0 ? _ref12 : 0),
1003
+ total: Number((_ref14 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref14 !== void 0 ? _ref14 : 0),
979
1004
  quantity: bundleItem.num || bundleItem.quantity || 1,
980
1005
  item: bundleItem,
981
1006
  mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
@@ -1191,9 +1216,9 @@ export var getSurcharge = function getSurcharge(_ref11, options) {
1191
1216
  }
1192
1217
  return surchargeWithAmount;
1193
1218
  };
1194
- function resetItemsSurchargeSideEffects(_ref13) {
1195
- var service = _ref13.service,
1196
- addons = _ref13.addons;
1219
+ function resetItemsSurchargeSideEffects(_ref15) {
1220
+ var service = _ref15.service,
1221
+ addons = _ref15.addons;
1197
1222
  var resetItem = function resetItem(item) {
1198
1223
  if (!item) return;
1199
1224
  item.surcharge_fee = 0;
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -1390,11 +1390,12 @@ export var ScanOrderImpl = /*#__PURE__*/function (_BaseModule) {
1390
1390
  })
1391
1391
  } : undefined;
1392
1392
  var ruleProductUid = ruleProduct ? createUuidV4() : undefined;
1393
- // 有 collect_pax 时 booking/resource capacity 都代表本次 pax;否则使用资源占用兜底值。
1393
+ // 有 collect_pax 时 booking/resource capacity 与 number 都代表本次 pax;否则使用资源占用兜底值。
1394
1394
  var bookingCapacityValue = resourceCapacityValue;
1395
1395
  var bookingCapacityDimensionId = (_pickFirstCustomCapac = pickFirstCustomCapacityDimensionId(_this5.enabledReservationRuleProducts)) !== null && _pickFirstCustomCapac !== void 0 ? _pickFirstCustomCapac : 0;
1396
1396
  var nextBookings = (payload.bookings || []).map(function (booking, idx) {
1397
1397
  return _objectSpread(_objectSpread(_objectSpread({}, booking), {}, {
1398
+ number: bookingCapacityValue,
1398
1399
  appointment_status: 'started',
1399
1400
  metadata: _objectSpread(_objectSpread(_objectSpread({}, booking.metadata || {}), resourceSelectType ? {
1400
1401
  resource_select_type: resourceSelectType
@@ -1,49 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/model/strategy/adapter/promotion/index.ts
30
- var promotion_exports = {};
31
- __export(promotion_exports, {
32
- BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
33
- PromotionAdapter: () => import_adapter.PromotionAdapter,
34
- PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
35
- X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
36
- default: () => import_adapter2.default
37
- });
38
- module.exports = __toCommonJS(promotion_exports);
39
- var import_evaluator = require("./evaluator");
40
- var import_adapter = require("./adapter");
41
- var import_adapter2 = __toESM(require("./adapter"));
42
- var import_examples = require("./examples");
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- BUY_X_GET_Y_FREE_STRATEGY,
46
- PromotionAdapter,
47
- PromotionEvaluator,
48
- X_ITEMS_FOR_Y_PRICE_STRATEGY
49
- });
@@ -59,7 +59,7 @@ function formatReason(template, value, currency = "") {
59
59
  return template;
60
60
  const v = value === void 0 || value === null ? "" : String(value);
61
61
  const c = currency === void 0 || currency === null ? "" : String(currency);
62
- return template.replace(/\$\{value\}/g, v).replace(/\{value\}/g, v).replace(/\{currency\}/g, c);
62
+ return template.replace(/\$\{value\}/g, () => v).replace(/\{value\}/g, () => v).replace(/\{currency\}/g, () => c);
63
63
  }
64
64
  var WalletPassEvaluator = class {
65
65
  constructor() {
@@ -214,6 +214,7 @@ var WalletPassEvaluator = class {
214
214
  }
215
215
  const rawText = this.getText(reasonCode);
216
216
  const currency = failedField && AMOUNT_FIELDS.has(failedField) ? ((_g = (_f = this.otherParams) == null ? void 0 : _f.getData) == null ? void 0 : _g.call(_f, "shop_symbol")) || "" : "";
217
+ console.log(currency, "currency12345");
217
218
  const reason = thresholdValue !== void 0 ? formatReason(rawText, thresholdValue, currency) : rawText;
218
219
  results.push({
219
220
  voucher,
@@ -437,11 +437,31 @@ var getBundleItemIsDiscountPrice = (item) => {
437
437
  var getBundleItemIsMarkupOrDiscountPrice = (item) => {
438
438
  return getBundleItemIsMarkupPrice(item) || getBundleItemIsDiscountPrice(item);
439
439
  };
440
+ var getDiscountAmount = (discounts) => {
441
+ return (discounts || []).reduce((total, discount) => {
442
+ return total.add(new import_decimal.default(discount.amount || 0));
443
+ }, new import_decimal.default(0)).toNumber();
444
+ };
440
445
  var getMainProductTotal = (item) => {
441
- var _a, _b;
446
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
442
447
  let total = new import_decimal.default(
443
448
  (item == null ? void 0 : item.main_product_selling_price) ?? ((_a = item == null ? void 0 : item.metadata) == null ? void 0 : _a.main_product_selling_price) ?? ((_b = item == null ? void 0 : item.metadata) == null ? void 0 : _b.main_product_original_price) ?? 0
444
449
  );
450
+ const hasMainProductPrice = (item == null ? void 0 : item.main_product_selling_price) != null || ((_c = item == null ? void 0 : item.metadata) == null ? void 0 : _c.main_product_selling_price) != null || ((_d = item == null ? void 0 : item.metadata) == null ? void 0 : _d.main_product_original_price) != null;
451
+ if (!hasMainProductPrice) {
452
+ total = new import_decimal.default((item == null ? void 0 : item.main_product_selling_price) ?? ((_e = item == null ? void 0 : item.metadata) == null ? void 0 : _e.main_product_selling_price) ?? item.price ?? 0);
453
+ const discount = ((_g = (_f = item == null ? void 0 : item._origin) == null ? void 0 : _f.product) == null ? void 0 : _g.discount_list) || ((_j = (_i = (_h = item == null ? void 0 : item._originData) == null ? void 0 : _h.product) == null ? void 0 : _i.discount_list) == null ? void 0 : _j.filter((item2) => {
454
+ var _a2;
455
+ return !((_a2 = item2 == null ? void 0 : item2.metadata) == null ? void 0 : _a2.custom_product_bundle_map_id);
456
+ })) || [];
457
+ const mainProductDiscountAmount = getDiscountAmount(discount);
458
+ total = total.minus(mainProductDiscountAmount);
459
+ if ((item == null ? void 0 : item.option) && Array.isArray(item == null ? void 0 : item.option)) {
460
+ total = total.add(item == null ? void 0 : item.option.reduce((t, option) => {
461
+ return t.add(new import_decimal.default(option.price || 0).mul(option.num || 1));
462
+ }, new import_decimal.default(0)));
463
+ }
464
+ }
445
465
  for (let bundleItem of (item == null ? void 0 : item.bundle) || []) {
446
466
  if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
447
467
  const bundleItemTotal = new import_decimal.default(bundleItem.bundle_selling_price ?? bundleItem.price ?? 0);
@@ -311,7 +311,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
311
311
  date: string;
312
312
  status: string;
313
313
  week: string;
314
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
314
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
315
315
  }[]>;
316
316
  submitTimeSlot(timeSlots: TimeSliceItem): void;
317
317
  private getScheduleDataByIds;
@@ -867,6 +867,7 @@ var _ScanOrderImpl = class extends import_BaseModule.BaseModule {
867
867
  const bookingCapacityDimensionId = (0, import_utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
868
868
  const nextBookings = (payload.bookings || []).map((booking, idx) => ({
869
869
  ...booking,
870
+ number: bookingCapacityValue,
870
871
  appointment_status: "started",
871
872
  metadata: {
872
873
  ...booking.metadata || {},
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.523",
4
+ "version": "0.0.525",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",