@pisell/pisellos 0.0.236 → 0.0.238

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.
@@ -393,7 +393,11 @@ export declare enum CheckoutHooks {
393
393
  /** 订单取消 */
394
394
  OnOrderCancelled = "checkout:onOrderCancelled",
395
395
  /** 订单状态已清理 */
396
- OnOrderCleared = "checkout:onOrderCleared"
396
+ OnOrderCleared = "checkout:onOrderCleared",
397
+ /** 下单接口请求开始 */
398
+ OnOrderSubmitStart = "checkout:onOrderSubmitStart",
399
+ /** 下单接口请求完成 */
400
+ OnOrderSubmitEnd = "checkout:onOrderSubmitEnd"
397
401
  }
398
402
  /**
399
403
  * 结账状态数据
@@ -824,4 +828,34 @@ export interface CheckoutEventData {
824
828
  } | null;
825
829
  timestamp: number;
826
830
  };
831
+ /** 下单接口请求开始事件 */
832
+ orderSubmitStart: {
833
+ /** 订单UUID */
834
+ orderUuid: string;
835
+ /** 操作类型 */
836
+ operation: 'create' | 'update';
837
+ /** 是否手动同步 */
838
+ isManual: boolean;
839
+ /** 支付项数量 */
840
+ paymentItemCount: number;
841
+ timestamp: number;
842
+ };
843
+ /** 下单接口请求完成事件 */
844
+ orderSubmitEnd: {
845
+ /** 是否成功 */
846
+ success: boolean;
847
+ /** 订单UUID */
848
+ orderUuid: string;
849
+ /** 操作类型 */
850
+ operation: 'create' | 'update';
851
+ /** 是否手动同步 */
852
+ isManual: boolean;
853
+ /** 返回的订单ID(成功时) */
854
+ orderId?: string;
855
+ /** 错误信息(失败时) */
856
+ error?: string;
857
+ /** 耗时(毫秒) */
858
+ duration?: number;
859
+ timestamp: number;
860
+ };
827
861
  }
@@ -71,6 +71,8 @@ var CheckoutHooks = /* @__PURE__ */ ((CheckoutHooks2) => {
71
71
  CheckoutHooks2["OnShopDiscountChanged"] = "checkout:onShopDiscountChanged";
72
72
  CheckoutHooks2["OnOrderCancelled"] = "checkout:onOrderCancelled";
73
73
  CheckoutHooks2["OnOrderCleared"] = "checkout:onOrderCleared";
74
+ CheckoutHooks2["OnOrderSubmitStart"] = "checkout:onOrderSubmitStart";
75
+ CheckoutHooks2["OnOrderSubmitEnd"] = "checkout:onOrderSubmitEnd";
74
76
  return CheckoutHooks2;
75
77
  })(CheckoutHooks || {});
76
78
  // Annotate the CommonJS export names for ESM import in node:
@@ -47,6 +47,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
47
47
  private setDiscountList;
48
48
  private getDiscountList;
49
49
  private getCustomerWallet;
50
+ private bestDiscount;
50
51
  private loadPrepareConfig;
51
52
  }
52
53
  export default ShopDiscountImpl;
@@ -50,7 +50,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
50
50
  customer: null,
51
51
  productList: [],
52
52
  discount: null,
53
- rules: null
53
+ rules: null,
54
+ originalDiscountList: []
54
55
  };
55
56
  }
56
57
  // =========== 生命周期方法 ===========
@@ -241,6 +242,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
241
242
  };
242
243
  if (isAvailable) {
243
244
  this.setDiscountList(newDiscountList || []);
245
+ this.store.originalDiscountList = newDiscountList || [];
244
246
  this.setProductList(newProductList || []);
245
247
  if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
246
248
  await this.getCustomerWallet(
@@ -388,6 +390,22 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
388
390
  console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
389
391
  }
390
392
  }
393
+ async bestDiscount() {
394
+ var _a;
395
+ const newDiscountList = this.store.originalDiscountList;
396
+ this.setDiscountList(newDiscountList);
397
+ if ((_a = this.store.productList) == null ? void 0 : _a.length) {
398
+ const result = this.calcDiscount(this.store.productList);
399
+ await this.core.effects.emit(
400
+ import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
401
+ result
402
+ );
403
+ }
404
+ await this.core.effects.emit(
405
+ import_types.ShopDiscountHooks.onLoadDiscountList,
406
+ newDiscountList
407
+ );
408
+ }
391
409
  // 加载准备配置
392
410
  async loadPrepareConfig(params) {
393
411
  var _a, _b, _c, _d;
@@ -405,6 +423,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
405
423
  const scanDiscountIds = scanDiscount.map((n) => n.id);
406
424
  const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
407
425
  const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
426
+ this.store.originalDiscountList = newDiscountList;
408
427
  this.setDiscountList(newDiscountList || []);
409
428
  if ((_d = this.store.productList) == null ? void 0 : _d.length) {
410
429
  const result = this.calcDiscount(this.store.productList);
@@ -1,4 +1,4 @@
1
- import { DiscountModule } from '../../modules/Discount';
1
+ import { DiscountModule, Discount } from '../../modules/Discount';
2
2
  import { RulesModule } from '../../modules/Rules';
3
3
  export declare enum ShopDiscountHooks {
4
4
  onInited = "shopDiscount:onInited",
@@ -22,4 +22,5 @@ export interface ShopDiscountState {
22
22
  discount: DiscountModule | null;
23
23
  rules: RulesModule | null;
24
24
  productList: Record<string, any>[];
25
+ originalDiscountList: Discount[];
25
26
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.236",
4
+ "version": "0.0.238",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",