@pisell/private-materials 6.6.58 → 6.6.59
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/render/default/view.js +1 -1
- package/build/lowcode/view.js +1 -1
- package/es/components/booking/info/service2/Group/utils.js +30 -1
- package/lib/components/booking/info/service2/Group/utils.js +42 -3
- package/package.json +3 -3
|
@@ -7,7 +7,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
7
7
|
import { getUniqueId } from "@pisell/utils";
|
|
8
8
|
import { getProductTotalPrice } from "../../../utils";
|
|
9
9
|
import { distributeDiscountOrIncrease } from "../../service/serviceManager/distributeDiscount";
|
|
10
|
+
import { setProductPrice } from "../../../info2/service/editService/utils";
|
|
10
11
|
import { genServiceKey } from "../../../../ticketBooking/utils";
|
|
12
|
+
import Decimal from "decimal.js";
|
|
11
13
|
|
|
12
14
|
// 创建group
|
|
13
15
|
|
|
@@ -121,7 +123,34 @@ export var createBookingItemsByGroup = function createBookingItemsByGroup(item,
|
|
|
121
123
|
// 折扣金额 转成负数
|
|
122
124
|
var discountAmount = (groupOriginTotalPrice - groupTotalPrice) * -1;
|
|
123
125
|
if (discountAmount !== 0) {
|
|
124
|
-
|
|
126
|
+
if (groupOriginTotalPrice !== 0) {
|
|
127
|
+
bookings = distributeDiscountOrIncrease(bookings, discountAmount, groupOriginTotalPrice);
|
|
128
|
+
bookings = bookings.map(function (booking) {
|
|
129
|
+
var _booking$_extend, _booking$_extend2;
|
|
130
|
+
return setProductPrice(booking, {
|
|
131
|
+
newTotal: booking === null || booking === void 0 || (_booking$_extend = booking._extend) === null || _booking$_extend === void 0 ? void 0 : _booking$_extend.total,
|
|
132
|
+
origin_total: booking === null || booking === void 0 || (_booking$_extend2 = booking._extend) === null || _booking$_extend2 === void 0 ? void 0 : _booking$_extend2.origin_total
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
} else {
|
|
136
|
+
// 原价为 0 无法按比例分摊(会除零),按 booking 数量均摊手动改价后的 groupTotalPrice
|
|
137
|
+
// 最后一个 booking 吸收两位小数的精度误差,确保总和等于 groupTotalPrice
|
|
138
|
+
var count = bookings.length;
|
|
139
|
+
var avgTotal = new Decimal(groupTotalPrice).div(count).toDecimalPlaces(2, Decimal.ROUND_HALF_UP);
|
|
140
|
+
var assignedSum = new Decimal(0);
|
|
141
|
+
bookings = bookings.map(function (booking, i) {
|
|
142
|
+
var newTotal = i === count - 1 ? new Decimal(groupTotalPrice).sub(assignedSum).toNumber() : avgTotal.toNumber();
|
|
143
|
+
if (i !== count - 1) {
|
|
144
|
+
assignedSum = assignedSum.add(avgTotal);
|
|
145
|
+
}
|
|
146
|
+
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
147
|
+
_extend: _objectSpread(_objectSpread({}, booking._extend), {}, {
|
|
148
|
+
total: newTotal,
|
|
149
|
+
price: newTotal
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
125
154
|
}
|
|
126
155
|
}
|
|
127
156
|
console.log('bookings', bookings);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/components/booking/info/service2/Group/utils.ts
|
|
@@ -31,7 +41,9 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
31
41
|
var import_utils = require("@pisell/utils");
|
|
32
42
|
var import_utils2 = require("../../../utils");
|
|
33
43
|
var import_distributeDiscount = require("../../service/serviceManager/distributeDiscount");
|
|
34
|
-
var import_utils3 = require("
|
|
44
|
+
var import_utils3 = require("../../../info2/service/editService/utils");
|
|
45
|
+
var import_utils4 = require("../../../../ticketBooking/utils");
|
|
46
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
35
47
|
var getGroupTotalPrice = (items) => {
|
|
36
48
|
return items.reduce((prev, next) => {
|
|
37
49
|
prev.duration += next._extend.duration;
|
|
@@ -100,7 +112,7 @@ var createBookingItemsByGroup = (item, isBatchEdit) => {
|
|
|
100
112
|
cacheItem._extend.total = totalPrice;
|
|
101
113
|
cacheItem._extend.origin_total = origin_total ?? totalPrice;
|
|
102
114
|
cacheItem._extend.items = void 0;
|
|
103
|
-
cacheItem._serviceKey = (0,
|
|
115
|
+
cacheItem._serviceKey = (0, import_utils4.genServiceKey)(cacheItem);
|
|
104
116
|
bookings.push(cacheItem);
|
|
105
117
|
}
|
|
106
118
|
if (isBatchEdit) {
|
|
@@ -108,7 +120,34 @@ var createBookingItemsByGroup = (item, isBatchEdit) => {
|
|
|
108
120
|
const groupOriginTotalPrice = item._extend.origin_total;
|
|
109
121
|
const discountAmount = (groupOriginTotalPrice - groupTotalPrice) * -1;
|
|
110
122
|
if (discountAmount !== 0) {
|
|
111
|
-
|
|
123
|
+
if (groupOriginTotalPrice !== 0) {
|
|
124
|
+
bookings = (0, import_distributeDiscount.distributeDiscountOrIncrease)(bookings, discountAmount, groupOriginTotalPrice);
|
|
125
|
+
bookings = bookings.map((booking) => {
|
|
126
|
+
var _a2, _b2;
|
|
127
|
+
return (0, import_utils3.setProductPrice)(booking, {
|
|
128
|
+
newTotal: (_a2 = booking == null ? void 0 : booking._extend) == null ? void 0 : _a2.total,
|
|
129
|
+
origin_total: (_b2 = booking == null ? void 0 : booking._extend) == null ? void 0 : _b2.origin_total
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
const count = bookings.length;
|
|
134
|
+
const avgTotal = new import_decimal.default(groupTotalPrice).div(count).toDecimalPlaces(2, import_decimal.default.ROUND_HALF_UP);
|
|
135
|
+
let assignedSum = new import_decimal.default(0);
|
|
136
|
+
bookings = bookings.map((booking, i) => {
|
|
137
|
+
const newTotal = i === count - 1 ? new import_decimal.default(groupTotalPrice).sub(assignedSum).toNumber() : avgTotal.toNumber();
|
|
138
|
+
if (i !== count - 1) {
|
|
139
|
+
assignedSum = assignedSum.add(avgTotal);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
...booking,
|
|
143
|
+
_extend: {
|
|
144
|
+
...booking._extend,
|
|
145
|
+
total: newTotal,
|
|
146
|
+
price: newTotal
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
}
|
|
112
151
|
}
|
|
113
152
|
}
|
|
114
153
|
console.log("bookings", bookings);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/private-materials",
|
|
3
|
-
"version": "6.6.
|
|
3
|
+
"version": "6.6.59",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@use-gesture/react": "^10.3.1",
|
|
64
64
|
"@pisell/utils": "3.0.2",
|
|
65
65
|
"@pisell/materials": "6.6.14",
|
|
66
|
-
"@pisell/
|
|
67
|
-
"@pisell/
|
|
66
|
+
"@pisell/date-picker": "3.0.7",
|
|
67
|
+
"@pisell/icon": "0.0.11"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": "^18.0.0",
|