@pisell/pisellos 0.0.228 → 0.0.230

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 (44) hide show
  1. package/dist/modules/Discount/index.d.ts +2 -1
  2. package/dist/modules/Discount/index.js +67 -4
  3. package/dist/modules/Discount/types.d.ts +25 -0
  4. package/dist/modules/Payment/index.d.ts +59 -6
  5. package/dist/modules/Payment/index.js +823 -504
  6. package/dist/modules/Payment/types.d.ts +62 -32
  7. package/dist/modules/Payment/types.js +2 -2
  8. package/dist/modules/Payment/walletpass.d.ts +0 -0
  9. package/dist/modules/Payment/walletpass.js +0 -0
  10. package/dist/solution/BookingByStep/index.js +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +1 -1
  12. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  13. package/dist/solution/Checkout/index.d.ts +181 -0
  14. package/dist/solution/Checkout/index.js +1596 -0
  15. package/dist/solution/Checkout/types.d.ts +550 -0
  16. package/dist/solution/Checkout/types.js +132 -0
  17. package/dist/solution/Checkout/utils/index.d.ts +73 -0
  18. package/dist/solution/Checkout/utils/index.js +371 -0
  19. package/dist/solution/ShopDiscount/index.d.ts +1 -1
  20. package/dist/solution/ShopDiscount/index.js +6 -6
  21. package/dist/solution/index.d.ts +1 -0
  22. package/dist/solution/index.js +2 -1
  23. package/lib/modules/Discount/index.d.ts +2 -1
  24. package/lib/modules/Discount/index.js +45 -3
  25. package/lib/modules/Discount/types.d.ts +25 -0
  26. package/lib/modules/Payment/index.d.ts +59 -6
  27. package/lib/modules/Payment/index.js +203 -64
  28. package/lib/modules/Payment/types.d.ts +62 -32
  29. package/lib/modules/Payment/walletpass.d.ts +0 -0
  30. package/lib/modules/Payment/walletpass.js +0 -0
  31. package/lib/solution/BookingByStep/index.js +1 -1
  32. package/lib/solution/BookingTicket/index.d.ts +1 -1
  33. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  34. package/lib/solution/Checkout/index.d.ts +181 -0
  35. package/lib/solution/Checkout/index.js +864 -0
  36. package/lib/solution/Checkout/types.d.ts +550 -0
  37. package/lib/solution/Checkout/types.js +75 -0
  38. package/lib/solution/Checkout/utils/index.d.ts +73 -0
  39. package/lib/solution/Checkout/utils/index.js +266 -0
  40. package/lib/solution/ShopDiscount/index.d.ts +1 -1
  41. package/lib/solution/ShopDiscount/index.js +2 -2
  42. package/lib/solution/index.d.ts +1 -0
  43. package/lib/solution/index.js +3 -1
  44. package/package.json +1 -1
@@ -20,8 +20,9 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
20
20
  with_discount_card: 0 | 1;
21
21
  customer_id: number;
22
22
  }): Promise<Discount[]>;
23
- batchSearch(code: string): Promise<Discount[]>;
23
+ batchSearch(code: string, customerId?: number): Promise<Discount[]>;
24
24
  filterEnabledDiscountList(discountList: Discount[]): Discount[];
25
+ private checkUsageCreditsLimit;
25
26
  uniqueByProductId(discountList: Discount[]): Discount[];
26
27
  filterDiscountListByProductIds(discountList: Discount[], productIds: number[]): Discount[];
27
28
  calcDiscountApplicableProductTotalPrice(discount: Discount): number | undefined;
@@ -145,7 +145,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
145
145
  }, {
146
146
  key: "batchSearch",
147
147
  value: function () {
148
- var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code) {
148
+ var _batchSearch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(code, customerId) {
149
149
  var result, resultDiscountList;
150
150
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
151
151
  while (1) switch (_context4.prev = _context4.next) {
@@ -156,7 +156,10 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
156
156
  translate_flag: 1,
157
157
  tags: ['good_pass', 'product_discount_card'],
158
158
  available: 1,
159
- relation_product: 1
159
+ relation_product: 1,
160
+ with: ['extensionData'],
161
+ order_behavior_count: 1,
162
+ order_behavior_count_customer_id: customerId || 1
160
163
  });
161
164
  case 2:
162
165
  result = _context4.sent;
@@ -168,7 +171,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
168
171
  }
169
172
  }, _callee4, this);
170
173
  }));
171
- function batchSearch(_x5) {
174
+ function batchSearch(_x5, _x6) {
172
175
  return _batchSearch.apply(this, arguments);
173
176
  }
174
177
  return batchSearch;
@@ -176,11 +179,71 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
176
179
  }, {
177
180
  key: "filterEnabledDiscountList",
178
181
  value: function filterEnabledDiscountList(discountList) {
182
+ var _this2 = this;
179
183
  return discountList.filter(function (discount) {
180
- return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0);
184
+ return discount.limit_status === 'enable' && new Decimal((discount === null || discount === void 0 ? void 0 : discount.par_value) || 0).minus(new Decimal((discount === null || discount === void 0 ? void 0 : discount.used_par_value) || 0)).greaterThan(0) && _this2.checkUsageCreditsLimit(discount);
181
185
  });
182
186
  }
183
187
 
188
+ // 检查使用次数限制
189
+ }, {
190
+ key: "checkUsageCreditsLimit",
191
+ value: function checkUsageCreditsLimit(discount) {
192
+ // 如果没有 extension_data,则不需要限制
193
+ if (!discount.extension_data || discount.extension_data.length === 0) {
194
+ return true;
195
+ }
196
+
197
+ // 查找 field_key 为 usage_credits 的数据
198
+ var usageCreditsData = discount.extension_data.find(function (data) {
199
+ return data.field_key === 'usage_credits';
200
+ });
201
+
202
+ // 如果没有找到 usage_credits 数据,则不需要限制
203
+ if (!usageCreditsData) {
204
+ return true;
205
+ }
206
+ var value = usageCreditsData.value;
207
+
208
+ // 检查总次数限制
209
+ if (value.total_credits && value.total_credits > 0) {
210
+ if ((discount.total_order_behavior_count || 0) >= value.total_credits) {
211
+ return false;
212
+ }
213
+ }
214
+
215
+ // 检查单用户限制
216
+ if (value.per_user_limit && value.per_user_limit > 0) {
217
+ if ((discount.customer_order_behavior_count || 0) >= value.per_user_limit) {
218
+ return false;
219
+ }
220
+ }
221
+
222
+ // 检查单日限制
223
+ if (value.max_per_day && value.max_per_day > 0) {
224
+ if ((discount.today_order_behavior_count || 0) >= value.max_per_day) {
225
+ return false;
226
+ }
227
+ }
228
+
229
+ // 检查单周限制
230
+ if (value.max_per_week && value.max_per_week > 0) {
231
+ if ((discount.week_order_behavior_count || 0) >= value.max_per_week) {
232
+ return false;
233
+ }
234
+ }
235
+
236
+ // 检查单月限制
237
+ if (value.max_per_month && value.max_per_month > 0) {
238
+ if ((discount.month_order_behavior_count || 0) >= value.max_per_month) {
239
+ return false;
240
+ }
241
+ }
242
+
243
+ // 所有检查都通过
244
+ return true;
245
+ }
246
+
184
247
  // 根据productIds去重
185
248
  }, {
186
249
  key: "uniqueByProductId",
@@ -36,6 +36,25 @@ interface ApplicableProductDetails {
36
36
  title?: string;
37
37
  };
38
38
  }
39
+ interface UsageCreditsValue {
40
+ total_credits: number;
41
+ per_user_limit: number;
42
+ max_per_day: number;
43
+ max_per_week: number;
44
+ max_per_month: number;
45
+ }
46
+ interface ExtensionData {
47
+ id: number;
48
+ shop_id: number;
49
+ product_id: number;
50
+ field_id: number;
51
+ field_key: string;
52
+ type: string;
53
+ value: UsageCreditsValue | Record<string, any> | string | number | boolean | any[];
54
+ created_at: string | null;
55
+ updated_at: string | null;
56
+ deleted_at: string | null;
57
+ }
39
58
  export interface Discount {
40
59
  id: number;
41
60
  product_name: string;
@@ -70,6 +89,12 @@ export interface Discount {
70
89
  appliedProductDetails: ApplicableProductDetails[];
71
90
  isDisabledForProductUsed?: boolean;
72
91
  amount?: number;
92
+ extension_data?: ExtensionData[];
93
+ total_order_behavior_count?: number;
94
+ today_order_behavior_count?: number;
95
+ week_order_behavior_count?: number;
96
+ month_order_behavior_count?: number;
97
+ customer_order_behavior_count?: number;
73
98
  }
74
99
  export interface DiscountState {
75
100
  discountList: Discount[];
@@ -86,15 +86,25 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
86
86
  */
87
87
  getOrderListAsync(): Promise<PaymentOrder[]>;
88
88
  /**
89
- * 根据uuid获取指定订单
89
+ * 根据订单UUID获取支付订单(新方法)
90
90
  */
91
- getOrderByUuidAsync(orderUuid: string): Promise<PaymentOrder | null>;
91
+ getPaymentOrderByUuidAsync(orderUuid: string): Promise<PaymentOrder | null>;
92
92
  /**
93
- * 往交易组中添加订单
93
+ * 创建支付订单(新方法,专注支付数据)
94
+ */
95
+ createPaymentOrderAsync(params: PushOrderParams): Promise<PaymentOrder>;
96
+ /**
97
+ * 往交易组中添加订单(兼容性方法)
98
+ * @deprecated 使用 createPaymentOrderAsync 替代
94
99
  */
95
100
  pushOrderAsync(params: PushOrderParams): Promise<PaymentOrder>;
96
101
  /**
97
- * 删除订单
102
+ * 删除支付订单(新方法)
103
+ */
104
+ deletePaymentOrderAsync(orderUuid: string): Promise<void>;
105
+ /**
106
+ * 删除订单(兼容性方法)
107
+ * @deprecated 使用 deletePaymentOrderAsync 替代
98
108
  */
99
109
  deleteOrderAsync(orderUuid: string): Promise<void>;
100
110
  /**
@@ -102,11 +112,32 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
102
112
  */
103
113
  updateOrderAsync(orderUuid: string, params: Partial<PaymentOrder>): Promise<void>;
104
114
  /**
105
- * 获取支付项
115
+ * 基于UUID替换订单ID
116
+ *
117
+ * 此方法用于将本地虚拟订单ID替换为真实的订单ID。
118
+ * 当前端模拟下单流程完成后,后端返回真实订单ID时调用此方法。
119
+ *
120
+ * @param orderUuid 订单的UUID
121
+ * @param newOrderId 新的订单ID (来自后端)
122
+ * @returns 更新后的订单对象,如果订单不存在则返回null
123
+ */
124
+ replaceOrderIdByUuidAsync(orderUuid: string, newOrderId: string): Promise<PaymentOrder | null>;
125
+ /**
126
+ * 获取支付项(新方法)
127
+ */
128
+ getPaymentItemsAsync(orderUuid: string): Promise<PaymentItem[]>;
129
+ /**
130
+ * 获取支付项(兼容性方法)
131
+ * @deprecated 使用 getPaymentItemsAsync 替代
106
132
  */
107
133
  getPaymentAsync(orderUuid: string): Promise<PaymentItem[]>;
108
134
  /**
109
- * 为某个订单设置一个支付项
135
+ * 为某个订单添加支付项(新方法)
136
+ */
137
+ addPaymentItemAsync(orderUuid: string, paymentItem: PaymentItemInput): Promise<void>;
138
+ /**
139
+ * 为某个订单设置一个支付项(兼容性方法)
140
+ * @deprecated 使用 addPaymentItemAsync 替代
110
141
  */
111
142
  pushPaymentAsync(orderUuid: string, paymentItem: PaymentItemInput): Promise<void>;
112
143
  /**
@@ -224,4 +255,26 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
224
255
  * @returns Promise<boolean> 是否成功添加到队列
225
256
  */
226
257
  private reAddOrderToSyncQueue;
258
+ /**
259
+ * 删除支付项(新方法)
260
+ */
261
+ deletePaymentItemAsync(orderUuid: string, paymentUuid: string): Promise<void>;
262
+ /**
263
+ * 更新支付项(新方法)
264
+ */
265
+ updatePaymentItemAsync(orderUuid: string, paymentUuid: string, params: PaymentUpdateFields): Promise<void>;
266
+ /**
267
+ * 获取订单剩余待付金额(新方法)
268
+ */
269
+ getRemainingAmountAsync(orderUuid: string): Promise<number>;
270
+ /**
271
+ * 获取订单剩余待付金额(基于用户输入的金额)(新方法)
272
+ */
273
+ getRemainingAmountWithInputAsync(inputAmount: string | number, orderUuid: string): Promise<number>;
274
+ /**
275
+ * 提交支付(新方法)
276
+ */
277
+ submitPaymentAsync(orderUuid: string): Promise<{
278
+ status: 'success' | 'failed';
279
+ }>;
227
280
  }