@pisell/pisellos 1.0.86 → 1.0.87
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.
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +37 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +31 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -742,6 +742,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
742
742
|
};
|
|
743
743
|
appliedProducts.push(discountDetail);
|
|
744
744
|
appliedDiscountProducts.set(_selectedDiscount.id, appliedProducts);
|
|
745
|
+
var total = targetProductTotal;
|
|
746
|
+
if (product.options) {
|
|
747
|
+
total = product.options.reduce(function (accumulator, currentValue) {
|
|
748
|
+
var currentPrice = new Decimal(currentValue.price || 0);
|
|
749
|
+
var currentNum = new Decimal(currentValue.num || 0);
|
|
750
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
751
|
+
}, new Decimal(total)).toNumber();
|
|
752
|
+
}
|
|
745
753
|
|
|
746
754
|
// 记录应用了优惠券的商品
|
|
747
755
|
// 后续更新价格改为 getProductTotalPrice getProductOriginTotalPrice逻辑
|
|
@@ -760,7 +768,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
768
|
}),
|
|
761
769
|
variant: originProduct._productInit.variant,
|
|
762
770
|
original_price: new Decimal(product.price || 0).toNumber(),
|
|
763
|
-
total:
|
|
771
|
+
total: total
|
|
764
772
|
}));
|
|
765
773
|
} else {
|
|
766
774
|
arr.push(_this3.hooks.setProduct(originProduct, {
|
|
@@ -768,7 +776,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
768
776
|
_id: product._id.split('___')[0] + "___" + _selectedDiscount.id + index,
|
|
769
777
|
price: _selectedDiscount.tag === 'good_pass' ? 0 : product.price,
|
|
770
778
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
771
|
-
total:
|
|
779
|
+
total: total,
|
|
772
780
|
origin_total: productOriginTotal,
|
|
773
781
|
main_product_selling_price: targetProductTotal
|
|
774
782
|
}));
|
|
@@ -1071,6 +1079,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1071
1079
|
});
|
|
1072
1080
|
}
|
|
1073
1081
|
|
|
1082
|
+
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
1083
|
+
if (product !== null && product !== void 0 && product.options) {
|
|
1084
|
+
newTotalWithDiscount = product.options.reduce(function (accumulator, currentValue) {
|
|
1085
|
+
var currentPrice = new Decimal(currentValue.price || 0);
|
|
1086
|
+
var currentNum = new Decimal(currentValue.num || 0);
|
|
1087
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
1088
|
+
}, new Decimal(newTotalWithDiscount)).toNumber();
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1074
1091
|
// 添加第一个主商品:qty=1,包含拆分后的bundle
|
|
1075
1092
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1076
1093
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_discount"),
|
|
@@ -1132,6 +1149,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1132
1149
|
});
|
|
1133
1150
|
}
|
|
1134
1151
|
|
|
1152
|
+
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
1153
|
+
if (product !== null && product !== void 0 && product.options) {
|
|
1154
|
+
newTotalOriginal = product.options.reduce(function (accumulator, currentValue) {
|
|
1155
|
+
var currentPrice = new Decimal(currentValue.price || 0);
|
|
1156
|
+
var currentNum = new Decimal(currentValue.num || 0);
|
|
1157
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
1158
|
+
}, new Decimal(newTotalOriginal)).toNumber();
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1135
1161
|
// 添加第二个主商品:qty=原quantity-1,包含原始bundle
|
|
1136
1162
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1137
1163
|
_id: "".concat(mainProductData._id.split('___')[0], "___split_normal"),
|
|
@@ -1227,6 +1253,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1227
1253
|
}
|
|
1228
1254
|
}
|
|
1229
1255
|
|
|
1256
|
+
// 累加options的价格(options不参与折扣,在最终设置total时处理)
|
|
1257
|
+
if (product !== null && product !== void 0 && product.options) {
|
|
1258
|
+
newTotal = product.options.reduce(function (accumulator, currentValue) {
|
|
1259
|
+
var currentPrice = new Decimal(currentValue.price || 0);
|
|
1260
|
+
var currentNum = new Decimal(currentValue.num || 0);
|
|
1261
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
1262
|
+
}, new Decimal(newTotal)).toNumber();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1230
1265
|
// 生成最终的主商品
|
|
1231
1266
|
result.push(_this3.hooks.setProduct(mainProduct, _objectSpread(_objectSpread({}, mainProductData), {}, {
|
|
1232
1267
|
bundle: newBundle,
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
};
|
|
343
343
|
setOtherData(key: string, value: any): void;
|
|
344
344
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
345
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|
|
@@ -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(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -532,6 +532,14 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
532
532
|
};
|
|
533
533
|
appliedProducts.push(discountDetail);
|
|
534
534
|
appliedDiscountProducts.set(selectedDiscount2.id, appliedProducts);
|
|
535
|
+
let total = targetProductTotal;
|
|
536
|
+
if (product.options) {
|
|
537
|
+
total = product.options.reduce((accumulator, currentValue) => {
|
|
538
|
+
const currentPrice = new import_decimal.default(currentValue.price || 0);
|
|
539
|
+
const currentNum = new import_decimal.default(currentValue.num || 0);
|
|
540
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
541
|
+
}, new import_decimal.default(total)).toNumber();
|
|
542
|
+
}
|
|
535
543
|
if (product.isClient) {
|
|
536
544
|
debugger;
|
|
537
545
|
arr.push(this.hooks.setProduct(originProduct, {
|
|
@@ -547,7 +555,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
547
555
|
}),
|
|
548
556
|
variant: originProduct._productInit.variant,
|
|
549
557
|
original_price: new import_decimal.default(product.price || 0).toNumber(),
|
|
550
|
-
total
|
|
558
|
+
total
|
|
551
559
|
}));
|
|
552
560
|
} else {
|
|
553
561
|
arr.push(this.hooks.setProduct(originProduct, {
|
|
@@ -555,7 +563,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
555
563
|
_id: product._id.split("___")[0] + "___" + selectedDiscount2.id + index,
|
|
556
564
|
price: selectedDiscount2.tag === "good_pass" ? 0 : product.price,
|
|
557
565
|
quantity: isNeedSplit ? 1 : product.quantity,
|
|
558
|
-
total
|
|
566
|
+
total,
|
|
559
567
|
origin_total: productOriginTotal,
|
|
560
568
|
main_product_selling_price: targetProductTotal
|
|
561
569
|
}));
|
|
@@ -818,6 +826,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
818
826
|
newOriginTotalWithDiscount += Number(originalPrice) * Number(item.num);
|
|
819
827
|
});
|
|
820
828
|
}
|
|
829
|
+
if (product == null ? void 0 : product.options) {
|
|
830
|
+
newTotalWithDiscount = product.options.reduce((accumulator, currentValue) => {
|
|
831
|
+
const currentPrice = new import_decimal.default(currentValue.price || 0);
|
|
832
|
+
const currentNum = new import_decimal.default(currentValue.num || 0);
|
|
833
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
834
|
+
}, new import_decimal.default(newTotalWithDiscount)).toNumber();
|
|
835
|
+
}
|
|
821
836
|
result.push(
|
|
822
837
|
this.hooks.setProduct(mainProduct, {
|
|
823
838
|
...mainProductData,
|
|
@@ -868,6 +883,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
868
883
|
newOriginTotalOriginal += Number(item.price) * Number(item.num);
|
|
869
884
|
});
|
|
870
885
|
}
|
|
886
|
+
if (product == null ? void 0 : product.options) {
|
|
887
|
+
newTotalOriginal = product.options.reduce((accumulator, currentValue) => {
|
|
888
|
+
const currentPrice = new import_decimal.default(currentValue.price || 0);
|
|
889
|
+
const currentNum = new import_decimal.default(currentValue.num || 0);
|
|
890
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
891
|
+
}, new import_decimal.default(newTotalOriginal)).toNumber();
|
|
892
|
+
}
|
|
871
893
|
result.push(
|
|
872
894
|
this.hooks.setProduct(mainProduct, {
|
|
873
895
|
...mainProductData,
|
|
@@ -943,6 +965,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
943
965
|
});
|
|
944
966
|
}
|
|
945
967
|
}
|
|
968
|
+
if (product == null ? void 0 : product.options) {
|
|
969
|
+
newTotal = product.options.reduce((accumulator, currentValue) => {
|
|
970
|
+
const currentPrice = new import_decimal.default(currentValue.price || 0);
|
|
971
|
+
const currentNum = new import_decimal.default(currentValue.num || 0);
|
|
972
|
+
return accumulator.add(currentPrice.mul(currentNum));
|
|
973
|
+
}, new import_decimal.default(newTotal)).toNumber();
|
|
974
|
+
}
|
|
946
975
|
result.push(
|
|
947
976
|
this.hooks.setProduct(mainProduct, {
|
|
948
977
|
...mainProductData,
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
};
|
|
343
343
|
setOtherData(key: string, value: any): void;
|
|
344
344
|
getOtherData(key: string): any;
|
|
345
|
-
getProductTypeById(id: number): Promise<"
|
|
345
|
+
getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
|
|
346
346
|
/**
|
|
347
347
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
348
348
|
*
|