@pisell/pisellos 0.0.351 → 0.0.352

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -1154,8 +1154,9 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1154
1154
 
1155
1155
  // 如果是手动折扣,使用原有的total和origin_total,不重新计算
1156
1156
  if (isManualDiscount) {
1157
- newTotal = mainProductData.total || newTotal;
1158
- newOriginTotal = mainProductData.origin_total || newOriginTotal;
1157
+ var _mainProductData$tota, _mainProductData$orig;
1158
+ newTotal = (_mainProductData$tota = mainProductData.total) !== null && _mainProductData$tota !== void 0 ? _mainProductData$tota : newTotal;
1159
+ newOriginTotal = (_mainProductData$orig = mainProductData.origin_total) !== null && _mainProductData$orig !== void 0 ? _mainProductData$orig : newOriginTotal;
1159
1160
  } else {
1160
1161
  // 不是手动折扣时,才重新计算
1161
1162
  var _mainDiscountList = mainProductData.discount_list.filter(function (item) {
@@ -383,43 +383,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
383
383
  return pre + (item.amount || 0);
384
384
  }, 0);
385
385
  };
386
- var productList = ((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
387
- return {
388
- product_id: item.product.product_id,
389
- product_variant_id: item.product.product_variant_id,
390
- quantity: item.product.num,
391
- // 整个商品折扣后的总金额
392
- selling_price: item.product.calculated_selling_price,
393
- // 整个商品折扣前的总金额
394
- original_price: item.product.calculated_original_price,
395
- // 主商品折扣前金额,不包含套餐子商品
396
- main_product_original_price: item.product.price,
397
- // 主商品折扣后金额,不包含套餐子商品
398
- main_product_selling_price: item.product.main_product_selling_price,
399
- product_bundle: item.product.product_bundle.map(function (bundle) {
400
- return {
401
- bundle_id: bundle.bundle_id,
402
- bundle_product_id: bundle.bundle_product_id,
403
- bundle_variant_id: bundle.bundle_variant_id,
404
- price_type: bundle.price_type,
405
- price_type_ext: bundle.price_type_ext,
406
- // 套餐子商品总价,不包含折扣金额
407
- bundle_sum_price: bundle.bundle_sum_price,
408
- // 套餐子商品折扣后金额
409
- bundle_selling_price: bundle.bundle_selling_price,
410
- num: bundle.num
411
- };
412
- })
413
- };
414
- })) || [];
415
- var relationProducts = ((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.relation_products) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.map(function (item) {
416
- return {
417
- product_id: item.product_id,
418
- product_variant_id: item.product_variant_id,
419
- quantity: item.num,
420
- selling_price: item.source_product_price
421
- };
422
- })) || [];
386
+ var formatProduct = function formatProduct(items) {
387
+ return items.map(function (item) {
388
+ return {
389
+ product_id: item.product_id,
390
+ product_variant_id: item.product_variant_id,
391
+ quantity: item.num,
392
+ // 整个商品折扣后的总金额
393
+ selling_price: item.calculated_selling_price,
394
+ // 整个商品折扣前的总金额
395
+ original_price: item.calculated_original_price,
396
+ // 主商品折扣前金额,不包含套餐子商品
397
+ main_product_original_price: item.price,
398
+ // 主商品折扣后金额,不包含套餐子商品
399
+ main_product_selling_price: item.main_product_selling_price,
400
+ product_bundle: item.product_bundle.map(function (bundle) {
401
+ return {
402
+ bundle_id: bundle.bundle_id,
403
+ bundle_product_id: bundle.bundle_product_id,
404
+ bundle_variant_id: bundle.bundle_variant_id,
405
+ price_type: bundle.price_type,
406
+ price_type_ext: bundle.price_type_ext,
407
+ // 套餐子商品总价,不包含折扣金额
408
+ bundle_sum_price: bundle.bundle_sum_price,
409
+ // 套餐子商品折扣后金额
410
+ bundle_selling_price: bundle.bundle_selling_price,
411
+ num: bundle.num
412
+ };
413
+ })
414
+ };
415
+ }) || [];
416
+ };
417
+ var productList = formatProduct(((_this$store$currentOr = this.store.currentOrder.order_info) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.original_order_data) === null || _this$store$currentOr === void 0 || (_this$store$currentOr = _this$store$currentOr.bookings) === null || _this$store$currentOr === void 0 ? void 0 : _this$store$currentOr.map(function (item) {
418
+ return item.product;
419
+ })) || []);
420
+ var relationProducts = formatProduct(((_this$store$currentOr2 = this.store.currentOrder.order_info) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.original_order_data) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.relation_products) || []);
423
421
  return [].concat(_toConsumableArray(productList), _toConsumableArray(relationProducts));
424
422
  }
425
423
  }, {
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -877,8 +877,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
877
877
  let newOriginTotal = Number(mainProductData.original_price || mainProductData.price || 0);
878
878
  const isManualDiscount = typeof mainProductData.isManualDiscount === "boolean" ? mainProductData.isManualDiscount : mainProductData.total != mainProductData.origin_total && (!((_a = mainProductData.discount_list) == null ? void 0 : _a.length) || ((_c = (_b = mainProductData == null ? void 0 : mainProductData.discount_list) == null ? void 0 : _b.every) == null ? void 0 : _c.call(_b, (item) => item.type === "product")));
879
879
  if (isManualDiscount) {
880
- newTotal = mainProductData.total || newTotal;
881
- newOriginTotal = mainProductData.origin_total || newOriginTotal;
880
+ newTotal = mainProductData.total ?? newTotal;
881
+ newOriginTotal = mainProductData.origin_total ?? newOriginTotal;
882
882
  } else {
883
883
  const mainDiscountList = mainProductData.discount_list.filter((item) => {
884
884
  var _a2;
@@ -206,43 +206,39 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
206
206
  return pre + (item.amount || 0);
207
207
  }, 0);
208
208
  };
209
- const productList = ((_b = (_a = this.store.currentOrder.order_info) == null ? void 0 : _a.original_order_data.bookings) == null ? void 0 : _b.map(
210
- (item) => ({
211
- product_id: item.product.product_id,
212
- product_variant_id: item.product.product_variant_id,
213
- quantity: item.product.num,
214
- // 整个商品折扣后的总金额
215
- selling_price: item.product.calculated_selling_price,
216
- // 整个商品折扣前的总金额
217
- original_price: item.product.calculated_original_price,
218
- // 主商品折扣前金额,不包含套餐子商品
219
- main_product_original_price: item.product.price,
220
- // 主商品折扣后金额,不包含套餐子商品
221
- main_product_selling_price: item.product.main_product_selling_price,
222
- product_bundle: item.product.product_bundle.map((bundle) => {
223
- return {
224
- bundle_id: bundle.bundle_id,
225
- bundle_product_id: bundle.bundle_product_id,
226
- bundle_variant_id: bundle.bundle_variant_id,
227
- price_type: bundle.price_type,
228
- price_type_ext: bundle.price_type_ext,
229
- // 套餐子商品总价,不包含折扣金额
230
- bundle_sum_price: bundle.bundle_sum_price,
231
- // 套餐子商品折扣后金额
232
- bundle_selling_price: bundle.bundle_selling_price,
233
- num: bundle.num
234
- };
209
+ const formatProduct = (items) => {
210
+ return items.map(
211
+ (item) => ({
212
+ product_id: item.product_id,
213
+ product_variant_id: item.product_variant_id,
214
+ quantity: item.num,
215
+ // 整个商品折扣后的总金额
216
+ selling_price: item.calculated_selling_price,
217
+ // 整个商品折扣前的总金额
218
+ original_price: item.calculated_original_price,
219
+ // 主商品折扣前金额,不包含套餐子商品
220
+ main_product_original_price: item.price,
221
+ // 主商品折扣后金额,不包含套餐子商品
222
+ main_product_selling_price: item.main_product_selling_price,
223
+ product_bundle: item.product_bundle.map((bundle) => {
224
+ return {
225
+ bundle_id: bundle.bundle_id,
226
+ bundle_product_id: bundle.bundle_product_id,
227
+ bundle_variant_id: bundle.bundle_variant_id,
228
+ price_type: bundle.price_type,
229
+ price_type_ext: bundle.price_type_ext,
230
+ // 套餐子商品总价,不包含折扣金额
231
+ bundle_sum_price: bundle.bundle_sum_price,
232
+ // 套餐子商品折扣后金额
233
+ bundle_selling_price: bundle.bundle_selling_price,
234
+ num: bundle.num
235
+ };
236
+ })
235
237
  })
236
- })
237
- )) || [];
238
- 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(
239
- (item) => ({
240
- product_id: item.product_id,
241
- product_variant_id: item.product_variant_id,
242
- quantity: item.num,
243
- selling_price: item.source_product_price
244
- })
245
- )) || [];
238
+ ) || [];
239
+ };
240
+ const productList = formatProduct(((_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((item) => item.product)) || []);
241
+ const relationProducts = formatProduct(((_e = (_d = this.store.currentOrder.order_info) == null ? void 0 : _d.original_order_data) == null ? void 0 : _e.relation_products) || []);
246
242
  return [...productList, ...relationProducts];
247
243
  }
248
244
  async initWalletData(params) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.351",
4
+ "version": "0.0.352",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",