@pisell/pisellos 3.0.6 → 3.0.7

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.
@@ -305,59 +305,59 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
305
305
  }), {}, {
306
306
  discount_list: []
307
307
  })));
308
- return;
309
- }
310
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
311
- return;
312
308
  }
309
+ return;
310
+ }
311
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
312
+ return;
313
+ }
313
314
 
314
- // 标记优惠券为已使用
315
- usedDiscounts.set(selectedDiscount.id, true);
316
-
317
- // 记录实际应用了优惠券的商品信息
318
- var appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
319
- var discountDetail = {
320
- amount: product.price,
321
- type: selectedDiscount.tag,
322
- discount: {
323
- resource_id: selectedDiscount.id,
324
- title: selectedDiscount.format_title,
325
- original_amount: product.origin_total,
326
- product_id: selectedDiscount.product_id
327
- }
328
- };
329
- appliedProducts.push(discountDetail);
330
- appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
331
-
332
- // 记录应用了优惠券的商品
333
- // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
334
- if (product.isClient) {
335
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
336
- discount_list: [discountDetail],
337
- price: 0,
338
- origin_total: getProductOriginTotalPrice({
339
- product: {
340
- original_price: product.original_price
341
- },
342
- bundle: product.bundle,
343
- options: product.options
344
- }),
345
- total: getProductTotalPrice({
346
- product: {
347
- price: '0'
348
- },
349
- bundle: product.bundle,
350
- options: product.options
351
- })
352
- }));
353
- } else {
354
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
355
- discount_list: [discountDetail],
356
- price: 0,
357
- total: (product.origin_total || product.total) - product.price,
358
- origin_total: product.origin_total || product.total
359
- }));
315
+ // 标记优惠券为已使用
316
+ usedDiscounts.set(selectedDiscount.id, true);
317
+
318
+ // 记录实际应用了优惠券的商品信息
319
+ var appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
320
+ var discountDetail = {
321
+ amount: product.price,
322
+ type: selectedDiscount.tag,
323
+ discount: {
324
+ resource_id: selectedDiscount.id,
325
+ title: selectedDiscount.format_title,
326
+ original_amount: product.origin_total,
327
+ product_id: selectedDiscount.product_id
360
328
  }
329
+ };
330
+ appliedProducts.push(discountDetail);
331
+ appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
332
+
333
+ // 记录应用了优惠券的商品
334
+ // 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
335
+ if (product.isClient) {
336
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
337
+ discount_list: [discountDetail],
338
+ price: 0,
339
+ origin_total: getProductOriginTotalPrice({
340
+ product: {
341
+ original_price: product.original_price
342
+ },
343
+ bundle: product.bundle,
344
+ options: product.options
345
+ }),
346
+ total: getProductTotalPrice({
347
+ product: {
348
+ price: '0'
349
+ },
350
+ bundle: product.bundle,
351
+ options: product.options
352
+ })
353
+ }));
354
+ } else {
355
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
356
+ discount_list: [discountDetail],
357
+ price: 0,
358
+ total: (product.origin_total || product.total) - product.price,
359
+ origin_total: product.origin_total || product.total
360
+ }));
361
361
  }
362
362
  });
363
363
 
@@ -483,21 +483,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
483
483
  });
484
484
  case 3:
485
485
  result = _context7.sent;
486
- if (result !== null && result !== void 0 && result.data) {
487
- _result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
488
- this.setCustomer(customer);
486
+ if (!(result !== null && result !== void 0 && result.data)) {
487
+ _context7.next = 9;
488
+ break;
489
489
  }
490
- _context7.next = 10;
490
+ _result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
491
+ this.setCustomer(customer);
492
+ _context7.next = 9;
493
+ return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
494
+ case 9:
495
+ _context7.next = 14;
491
496
  break;
492
- case 7:
493
- _context7.prev = 7;
497
+ case 11:
498
+ _context7.prev = 11;
494
499
  _context7.t0 = _context7["catch"](0);
495
500
  console.error('[ShopDiscount] 获取客户钱包信息出错:', _context7.t0);
496
- case 10:
501
+ case 14:
497
502
  case "end":
498
503
  return _context7.stop();
499
504
  }
500
- }, _callee7, this, [[0, 7]]);
505
+ }, _callee7, this, [[0, 11]]);
501
506
  }));
502
507
  function getCustomerWallet(_x6) {
503
508
  return _getCustomerWallet.apply(this, arguments);
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
5
5
  onDestroy = "shopDiscount:onDestroy",
6
6
  onLoadDiscountList = "shopDiscount:onLoadDiscountList",
7
7
  onCustomerChange = "shopDiscount:onCustomerChange",
8
+ onScanCustomerChange = "shopDiscount:onScanCustomerChange",
8
9
  onDiscountListChange = "shopDiscount:onDiscountListChange",
9
10
  onRulesListChange = "shopDiscount:onRulesListChange",
10
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
@@ -3,6 +3,7 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
3
3
  ShopDiscountHooks["onDestroy"] = "shopDiscount:onDestroy";
4
4
  ShopDiscountHooks["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
5
5
  ShopDiscountHooks["onCustomerChange"] = "shopDiscount:onCustomerChange";
6
+ ShopDiscountHooks["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
6
7
  ShopDiscountHooks["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
7
8
  ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
8
9
  ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
@@ -210,58 +210,58 @@ var RulesModule = class extends import_BaseModule.BaseModule {
210
210
  discount_list: []
211
211
  })
212
212
  );
213
- return;
214
213
  }
215
- if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
216
- return;
214
+ return;
215
+ }
216
+ if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
217
+ return;
218
+ }
219
+ usedDiscounts.set(selectedDiscount.id, true);
220
+ const appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
221
+ const discountDetail = {
222
+ amount: product.price,
223
+ type: selectedDiscount.tag,
224
+ discount: {
225
+ resource_id: selectedDiscount.id,
226
+ title: selectedDiscount.format_title,
227
+ original_amount: product.origin_total,
228
+ product_id: selectedDiscount.product_id
217
229
  }
218
- usedDiscounts.set(selectedDiscount.id, true);
219
- const appliedProducts = appliedDiscountProducts.get(selectedDiscount.id) || [];
220
- const discountDetail = {
221
- amount: product.price,
222
- type: selectedDiscount.tag,
223
- discount: {
224
- resource_id: selectedDiscount.id,
225
- title: selectedDiscount.format_title,
226
- original_amount: product.origin_total,
227
- product_id: selectedDiscount.product_id
228
- }
229
- };
230
- appliedProducts.push(discountDetail);
231
- appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
232
- if (product.isClient) {
233
- processedProductsMap.set(
234
- product._id,
235
- this.hooks.setProduct(originProduct, {
236
- discount_list: [discountDetail],
237
- price: 0,
238
- origin_total: (0, import_utils2.getProductOriginTotalPrice)({
239
- product: {
240
- original_price: product.original_price
241
- },
242
- bundle: product.bundle,
243
- options: product.options
244
- }),
245
- total: (0, import_utils2.getProductTotalPrice)({
246
- product: {
247
- price: "0"
248
- },
249
- bundle: product.bundle,
250
- options: product.options
251
- })
252
- })
253
- );
254
- } else {
255
- processedProductsMap.set(
256
- product._id,
257
- this.hooks.setProduct(originProduct, {
258
- discount_list: [discountDetail],
259
- price: 0,
260
- total: (product.origin_total || product.total) - product.price,
261
- origin_total: product.origin_total || product.total
230
+ };
231
+ appliedProducts.push(discountDetail);
232
+ appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
233
+ if (product.isClient) {
234
+ processedProductsMap.set(
235
+ product._id,
236
+ this.hooks.setProduct(originProduct, {
237
+ discount_list: [discountDetail],
238
+ price: 0,
239
+ origin_total: (0, import_utils2.getProductOriginTotalPrice)({
240
+ product: {
241
+ original_price: product.original_price
242
+ },
243
+ bundle: product.bundle,
244
+ options: product.options
245
+ }),
246
+ total: (0, import_utils2.getProductTotalPrice)({
247
+ product: {
248
+ price: "0"
249
+ },
250
+ bundle: product.bundle,
251
+ options: product.options
262
252
  })
263
- );
264
- }
253
+ })
254
+ );
255
+ } else {
256
+ processedProductsMap.set(
257
+ product._id,
258
+ this.hooks.setProduct(originProduct, {
259
+ discount_list: [discountDetail],
260
+ price: 0,
261
+ total: (product.origin_total || product.total) - product.price,
262
+ origin_total: product.origin_total || product.total
263
+ })
264
+ );
265
265
  }
266
266
  });
267
267
  const processedProductList = productList.map((originProduct) => {
@@ -313,6 +313,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
313
313
  if (result == null ? void 0 : result.data) {
314
314
  const { wallet_pass_list, ...customer } = result.data;
315
315
  this.setCustomer(customer);
316
+ await this.core.effects.emit(
317
+ import_types.ShopDiscountHooks.onScanCustomerChange,
318
+ customer
319
+ );
316
320
  }
317
321
  } catch (error) {
318
322
  console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
5
5
  onDestroy = "shopDiscount:onDestroy",
6
6
  onLoadDiscountList = "shopDiscount:onLoadDiscountList",
7
7
  onCustomerChange = "shopDiscount:onCustomerChange",
8
+ onScanCustomerChange = "shopDiscount:onScanCustomerChange",
8
9
  onDiscountListChange = "shopDiscount:onDiscountListChange",
9
10
  onRulesListChange = "shopDiscount:onRulesListChange",
10
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
@@ -27,6 +27,7 @@ var ShopDiscountHooks = /* @__PURE__ */ ((ShopDiscountHooks2) => {
27
27
  ShopDiscountHooks2["onDestroy"] = "shopDiscount:onDestroy";
28
28
  ShopDiscountHooks2["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
29
29
  ShopDiscountHooks2["onCustomerChange"] = "shopDiscount:onCustomerChange";
30
+ ShopDiscountHooks2["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
30
31
  ShopDiscountHooks2["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
31
32
  ShopDiscountHooks2["onRulesListChange"] = "shopDiscount:onRulesListChange";
32
33
  ShopDiscountHooks2["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.6",
4
+ "version": "3.0.7",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",