@pisell/pisellos 2.2.15 → 2.2.17

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 (33) hide show
  1. package/dist/modules/Customer/index.js +1 -1
  2. package/dist/modules/Payment/index.js +2 -2
  3. package/dist/modules/Payment/types.d.ts +1 -0
  4. package/dist/modules/Payment/walletpass.js +3 -1
  5. package/dist/modules/ProductList/index.js +8 -9
  6. package/dist/modules/Rules/index.d.ts +4 -2
  7. package/dist/modules/Rules/index.js +94 -53
  8. package/dist/modules/Rules/types.d.ts +1 -0
  9. package/dist/solution/BookingByStep/index.js +29 -8
  10. package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
  11. package/dist/solution/BookingByStep/utils/products.js +10 -0
  12. package/dist/solution/BookingTicket/index.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +61 -17
  14. package/dist/solution/ShopDiscount/index.d.ts +4 -0
  15. package/dist/solution/ShopDiscount/index.js +13 -4
  16. package/dist/solution/ShopDiscount/types.d.ts +5 -1
  17. package/lib/modules/Customer/index.js +1 -1
  18. package/lib/modules/Payment/index.js +1 -1
  19. package/lib/modules/Payment/types.d.ts +1 -0
  20. package/lib/modules/Payment/walletpass.js +10 -1
  21. package/lib/modules/ProductList/index.js +0 -7
  22. package/lib/modules/Rules/index.d.ts +4 -2
  23. package/lib/modules/Rules/index.js +71 -52
  24. package/lib/modules/Rules/types.d.ts +1 -0
  25. package/lib/solution/BookingByStep/index.js +15 -2
  26. package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
  27. package/lib/solution/BookingByStep/utils/products.js +8 -2
  28. package/lib/solution/BookingTicket/index.d.ts +1 -1
  29. package/lib/solution/Checkout/index.js +66 -17
  30. package/lib/solution/ShopDiscount/index.d.ts +4 -0
  31. package/lib/solution/ShopDiscount/index.js +12 -5
  32. package/lib/solution/ShopDiscount/types.d.ts +5 -1
  33. package/package.json +2 -2
@@ -9,3 +9,9 @@ export declare const getAvailableProductResources: (products: ProductData[]) =>
9
9
  rules: any[];
10
10
  resourcesMap: Record<number, ProductResourceItem>;
11
11
  };
12
+ /**
13
+ * 判断商品是否是 session 商品
14
+ * @param product 商品数据
15
+ * @returns 是否是 session 商品
16
+ */
17
+ export declare const isSessionProduct: (product: ProductData) => boolean;
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/solution/BookingByStep/utils/products.ts
20
20
  var products_exports = {};
21
21
  __export(products_exports, {
22
- getAvailableProductResources: () => getAvailableProductResources
22
+ getAvailableProductResources: () => getAvailableProductResources,
23
+ isSessionProduct: () => isSessionProduct
23
24
  });
24
25
  module.exports = __toCommonJS(products_exports);
25
26
  var getAvailableProductResources = (products) => {
@@ -57,7 +58,12 @@ var getAvailableProductResources = (products) => {
57
58
  });
58
59
  return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap };
59
60
  };
61
+ var isSessionProduct = (product) => {
62
+ var _a;
63
+ return (((_a = product == null ? void 0 : product["schedule.ids"]) == null ? void 0 : _a.length) ?? 0) > 0;
64
+ };
60
65
  // Annotate the CommonJS export names for ESM import in node:
61
66
  0 && (module.exports = {
62
- getAvailableProductResources
67
+ getAvailableProductResources,
68
+ isSessionProduct
63
69
  });
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -216,23 +216,70 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
216
216
  return pre + (item.amount || 0);
217
217
  }, 0);
218
218
  };
219
- const productList = ((_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings) == null ? void 0 : _b.map(
220
- (item) => ({
221
- product_id: item.product.product_id,
222
- product_variant_id: item.product.product_variant_id,
223
- quantity: item.product.num,
224
- selling_price: item.product.calculated_selling_price,
225
- holder_id: this.getHolderIdFromBooking(item)
226
- })
227
- )) || [];
228
- const relationProducts = ((_e = (_d = (_c = this.store.currentOrder.order_info) == null ? void 0 : _c.original_order_data) == null ? void 0 : _d.relation_products) == null ? void 0 : _e.map(
229
- (item) => ({
230
- product_id: item.product_id,
231
- product_variant_id: item.product_variant_id,
232
- quantity: item.num,
233
- selling_price: item.source_product_price
234
- })
235
- )) || [];
219
+ const formatProduct = (items) => {
220
+ return items.map(
221
+ (item) => ({
222
+ product_id: item.product_id,
223
+ product_variant_id: item.product_variant_id,
224
+ quantity: item.num,
225
+ // 商品是否含税:1;0
226
+ is_charge_tax: item.is_charge_tax ?? 0,
227
+ // 若商品不含税,计算得到的税费,单位(元)
228
+ tax_fee: item.tax_fee,
229
+ // 整个商品折扣后的总金额
230
+ selling_price: item.calculated_selling_price,
231
+ // 使用者id
232
+ holder_id: item.holder_id,
233
+ // 整个商品折扣前的总金额
234
+ original_price: item.calculated_original_price,
235
+ // 主商品折扣前金额,不包含套餐子商品
236
+ main_product_original_price: item.price,
237
+ // 主商品折扣后金额,不包含套餐子商品
238
+ main_product_selling_price: item.main_product_selling_price,
239
+ metadata: {
240
+ // 主商品+非原价(加减价)子商品税费
241
+ "main_product_attached_bundle_tax_fee": item.metadata.main_product_attached_bundle_tax_fee,
242
+ // 主商品+非原价(加减价)子商品附加费
243
+ "main_product_attached_bundle_surcharge_fee": item.metadata.main_product_attached_bundle_surcharge_fee,
244
+ // 可选,附加费均摊舍入金额
245
+ "surcharge_rounding_remainder": item.metadata.surcharge_rounding_remainder
246
+ },
247
+ product_bundle: item.product_bundle.map((bundle) => {
248
+ return {
249
+ bundle_id: bundle.bundle_id,
250
+ bundle_product_id: bundle.bundle_product_id,
251
+ bundle_variant_id: bundle.bundle_variant_id,
252
+ price_type: bundle.price_type,
253
+ price_type_ext: bundle.price_type_ext,
254
+ // 套餐子商品总价,不包含折扣金额
255
+ bundle_sum_price: bundle.bundle_sum_price,
256
+ // 套餐子商品折扣后金额
257
+ bundle_selling_price: bundle.bundle_selling_price,
258
+ num: bundle.num,
259
+ is_charge_tax: bundle.is_charge_tax,
260
+ tax_fee: bundle.tax_fee,
261
+ metadata: {
262
+ // 子商品单数量附加费
263
+ "surcharge_fee": bundle.metadata.surcharge_fee,
264
+ // 可选,附加费均摊舍入金额
265
+ "surcharge_rounding_remainder": bundle.metadata.surcharge_rounding_remainder
266
+ }
267
+ };
268
+ })
269
+ })
270
+ ) || [];
271
+ };
272
+ const productList = formatProduct(
273
+ ((_c = (_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data) == null ? void 0 : _b.bookings) == null ? void 0 : _c.map(
274
+ (item) => {
275
+ return {
276
+ ...item.product,
277
+ holder_id: this.getHolderIdFromBooking(item)
278
+ };
279
+ }
280
+ )) || []
281
+ );
282
+ const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
236
283
  return [...productList, ...relationProducts];
237
284
  }
238
285
  async initWalletData(params) {
@@ -257,6 +304,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
257
304
  isDeposit: (_h = this.store.currentOrder) == null ? void 0 : _h.is_deposit
258
305
  },
259
306
  products: this.getProductListByOrder(),
307
+ is_price_include_tax: this.otherParams.is_price_include_tax,
308
+ // core 有
260
309
  ...params
261
310
  };
262
311
  if (this.store.isOrderSynced) {
@@ -24,6 +24,10 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
24
24
  setHolders(holders: {
25
25
  form_record_id: number;
26
26
  }[]): void;
27
+ setBookingSubject(bookingSubject: {
28
+ type?: 'form' | 'customer';
29
+ [key: string]: any;
30
+ }): void;
27
31
  calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
28
32
  productList: Record<string, any>[];
29
33
  discountList: Discount[];
@@ -51,10 +51,11 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
51
51
  productList: [],
52
52
  discount: null,
53
53
  rules: null,
54
+ holders: [],
54
55
  originalDiscountList: [],
55
56
  currentBookingTime: "",
56
57
  filteredDiscountList: [],
57
- holders: []
58
+ bookingSubject: void 0
58
59
  };
59
60
  }
60
61
  // =========== 生命周期方法 ===========
@@ -196,8 +197,12 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
196
197
  setHolders(holders) {
197
198
  this.store.holders = holders;
198
199
  }
200
+ setBookingSubject(bookingSubject) {
201
+ this.store.bookingSubject = bookingSubject;
202
+ }
199
203
  // 计算优惠券
200
204
  calcDiscount(productList, options) {
205
+ var _a;
201
206
  this.store.productList = productList;
202
207
  const rulesModule = this.core.getModule(`${this.name}_rules`);
203
208
  if (!rulesModule) {
@@ -207,7 +212,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
207
212
  {
208
213
  productList,
209
214
  discountList: this.getDiscountList(),
210
- holders: this.store.holders || []
215
+ holders: this.store.holders || [],
216
+ isFormSubject: ((_a = this.store.bookingSubject) == null ? void 0 : _a.type) === "form"
211
217
  },
212
218
  options
213
219
  ) || { productList, discountList: this.getDiscountList() };
@@ -254,7 +260,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
254
260
  }
255
261
  // 扫码输入code
256
262
  async scanCode(code, customerId) {
257
- var _a, _b;
263
+ var _a, _b, _c;
258
264
  try {
259
265
  const resultDiscountList = await ((_a = this.store.discount) == null ? void 0 : _a.batchSearch(code, customerId)) || [];
260
266
  const rulesModule = this.store.rules;
@@ -297,7 +303,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
297
303
  productList: this.store.productList || [],
298
304
  oldDiscountList: this.getDiscountList(),
299
305
  newDiscountList: withScanList,
300
- holders: this.store.holders || []
306
+ holders: this.store.holders || [],
307
+ isFormSubject: ((_b = this.store.bookingSubject) == null ? void 0 : _b.type) === "form"
301
308
  }) || {
302
309
  isAvailable: false,
303
310
  productList: this.store.productList || [],
@@ -307,7 +314,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
307
314
  this.setDiscountList(newDiscountList || []);
308
315
  this.store.originalDiscountList = newDiscountList || [];
309
316
  this.setProductList(newProductList || []);
310
- if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
317
+ if (this.isWalkIn() && resultDiscountList.length && ((_c = this.options.otherParams) == null ? void 0 : _c.platform) === "shop") {
311
318
  await this.getCustomerWallet(
312
319
  resultDiscountList[0].customer_id
313
320
  );
@@ -23,14 +23,18 @@ export interface ShopDiscountState {
23
23
  discount: DiscountModule | null;
24
24
  rules: RulesModule | null;
25
25
  productList: Record<string, any>[];
26
- originalDiscountList: Discount[];
27
26
  holders?: {
28
27
  form_record_id: number;
29
28
  form_id?: number;
30
29
  main_field?: string;
31
30
  }[];
31
+ originalDiscountList: Discount[];
32
32
  currentBookingTime: string | null;
33
33
  filteredDiscountList: Discount[];
34
+ bookingSubject?: {
35
+ type?: 'form' | 'customer';
36
+ [key: string]: any;
37
+ };
34
38
  }
35
39
  export interface SetDiscountSelectedParams {
36
40
  discountId: number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.15",
4
+ "version": "2.2.17",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -69,4 +69,4 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  }
72
- }
72
+ }