@pisell/pisellos 3.0.91 → 3.0.93

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.
@@ -0,0 +1,49 @@
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
+ });
@@ -33,6 +33,8 @@ interface Limitedrelationproductdata {
33
33
  product_ids: number[];
34
34
  product_collection_id: number[];
35
35
  package_sub_item_usage_rules?: PackageSubItemUsageRules;
36
+ exclude_product_ids?: number[];
37
+ filter?: 0 | 1;
36
38
  }
37
39
  interface ApplicableProductDetails {
38
40
  amount: string;
@@ -59,7 +59,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
59
59
  cacheId,
60
60
  menu_list_ids = []
61
61
  }) {
62
- var _a;
62
+ var _a, _b, _c;
63
63
  let userPlugin = this.core.getPlugin("user");
64
64
  let customer_id = void 0;
65
65
  try {
@@ -67,6 +67,13 @@ var ProductList = class extends import_BaseModule.BaseModule {
67
67
  } catch (error) {
68
68
  console.error(error);
69
69
  }
70
+ const channelMap = {
71
+ "online_store": "online-store",
72
+ "scan_to_order": "online-store",
73
+ "scan_to_order_2": "online-store",
74
+ "scan_to_order_3": "online-store"
75
+ };
76
+ const saleChannel = channelMap[(_b = this.otherParams) == null ? void 0 : _b.channel] || ((_c = this.otherParams) == null ? void 0 : _c.channel);
70
77
  try {
71
78
  const productsData = await this.request.post(
72
79
  `/product/query`,
@@ -93,8 +100,7 @@ var ProductList = class extends import_BaseModule.BaseModule {
93
100
  // client_schedule_ids: schedule_ids,
94
101
  schedule_date,
95
102
  schedule_datetime,
96
- // application_code: this.otherParams?.channel === 'online_store' ? 'online-store' : this.otherParams?.channel,
97
- application_code: "online-store",
103
+ application_code: saleChannel,
98
104
  is_eject: 1,
99
105
  menu_list_ids,
100
106
  open_deposit: 1
@@ -358,6 +358,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
358
358
  }
359
359
  return priceB.minus(priceA).toNumber();
360
360
  });
361
+ const isProductIncludedByLimitedData = (limitedData, productId) => {
362
+ const excludedIds = (limitedData == null ? void 0 : limitedData.exclude_product_ids) || [];
363
+ const isExcluded = (limitedData == null ? void 0 : limitedData.filter) === 1 && excludedIds.some((id) => String(id) === String(productId));
364
+ return !isExcluded;
365
+ };
361
366
  const usedDiscounts = /* @__PURE__ */ new Map();
362
367
  const discountApplicability = /* @__PURE__ */ new Map();
363
368
  const discountApplicableProducts = /* @__PURE__ */ new Map();
@@ -627,6 +632,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
627
632
  return false;
628
633
  }
629
634
  if (limitedData.type === "product_all") {
635
+ if (!isProductIncludedByLimitedData(limitedData, product.id)) {
636
+ return false;
637
+ }
630
638
  if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
631
639
  return false;
632
640
  }
@@ -373,6 +373,26 @@ var calculateTaxFee = (shopInfo, items) => {
373
373
  }, new import_decimal.default(0));
374
374
  return totalTaxFee;
375
375
  };
376
+ var getCartItemDepositData = (item) => {
377
+ var _a, _b, _c, _d;
378
+ const target = item;
379
+ return ((_a = target == null ? void 0 : target._productOrigin) == null ? void 0 : _a.custom_deposit_data) || ((_b = target == null ? void 0 : target._origin) == null ? void 0 : _b.custom_deposit_data) || ((_d = (_c = target == null ? void 0 : target._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.custom_deposit_data);
380
+ };
381
+ var getCartItemQuantity = (item) => {
382
+ return new import_decimal.default((item == null ? void 0 : item.num) || 1);
383
+ };
384
+ var calculateCartItemDepositTotal = (item) => {
385
+ var _a;
386
+ const depositData = getCartItemDepositData(item);
387
+ if ((depositData == null ? void 0 : depositData.has_deposit) == 1 && typeof (depositData == null ? void 0 : depositData.deposit_fixed) === "string" && typeof (depositData == null ? void 0 : depositData.deposit_percentage) === "string") {
388
+ const lineTotal = new import_decimal.default(item.summaryTotal ?? item.total ?? 0);
389
+ const quantity = getCartItemQuantity(item);
390
+ const fixedTotal = new import_decimal.default(depositData.deposit_fixed || 0).times(quantity);
391
+ const percentageTotal = new import_decimal.default(depositData.deposit_percentage || 0).times(lineTotal);
392
+ return fixedTotal.plus(percentageTotal);
393
+ }
394
+ return new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
395
+ };
376
396
  var calculateDeposit = (items) => {
377
397
  if (!(items == null ? void 0 : items.length)) {
378
398
  return void 0;
@@ -380,11 +400,11 @@ var calculateDeposit = (items) => {
380
400
  const protocols = [];
381
401
  let hasDeposit = false;
382
402
  const total = items.reduce((sum, item) => {
383
- var _a, _b, _c;
403
+ var _a, _b;
384
404
  if (item == null ? void 0 : item.deposit) {
385
405
  hasDeposit = true;
386
- const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
387
- (_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
406
+ const cartItemTotalPrice = calculateCartItemDepositTotal(item);
407
+ (_b = (_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.protocols) == null ? void 0 : _b.forEach((protocol) => {
388
408
  if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
389
409
  protocols.push(protocol);
390
410
  }
@@ -168,6 +168,11 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
168
168
  getOrderProducts(): ScanOrderOrderProduct[];
169
169
  getSummary(): Promise<import("./types").ScanOrderSummary>;
170
170
  submitOrder<T = any>(): Promise<T>;
171
+ /**
172
+ * 0 元订单免费领取(非定金场景)
173
+ * 与 appointment getFreeProduct 同接口:POST /pay/order/free-pay/:id
174
+ */
175
+ submitFreeOrder(id: string | number): Promise<any>;
171
176
  addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
172
177
  updateProductInOrder(params: UpdateProductInOrderParams): Promise<ScanOrderOrderProduct[]>;
173
178
  removeProductFromOrder(identity: ScanOrderOrderProductIdentity): Promise<ScanOrderOrderProduct[]>;
@@ -1437,6 +1437,24 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
1437
1437
  throw error;
1438
1438
  }
1439
1439
  }
1440
+ /**
1441
+ * 0 元订单免费领取(非定金场景)
1442
+ * 与 appointment getFreeProduct 同接口:POST /pay/order/free-pay/:id
1443
+ */
1444
+ async submitFreeOrder(id) {
1445
+ this.logMethodStart("submitFreeOrder", { id });
1446
+ try {
1447
+ if (!id) {
1448
+ throw new Error("订单 ID 不能为空");
1449
+ }
1450
+ const res = await this.request.post(`/pay/order/free-pay/${id}`);
1451
+ this.logMethodSuccess("submitFreeOrder", { id, status: res == null ? void 0 : res.status });
1452
+ return res;
1453
+ } catch (error) {
1454
+ this.logMethodError("submitFreeOrder", error);
1455
+ throw error;
1456
+ }
1457
+ }
1440
1458
  async addProductToOrder(product) {
1441
1459
  var _a;
1442
1460
  this.logMethodStart("addProductToOrder", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.91",
4
+ "version": "3.0.93",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",