@yoooloo42/bean 1.0.34 → 1.0.35
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/index.cjs.js +117 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +117 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -4175,6 +4175,121 @@ var GBT = {
|
|
|
4175
4175
|
gbt4658
|
|
4176
4176
|
};
|
|
4177
4177
|
|
|
4178
|
+
var busicode = {
|
|
4179
|
+
method: [
|
|
4180
|
+
{"code": "0", "text": "日结"},
|
|
4181
|
+
{"code": "1", "text": "小时"},
|
|
4182
|
+
{"code": "2", "text": "月结"}
|
|
4183
|
+
]
|
|
4184
|
+
};
|
|
4185
|
+
|
|
4186
|
+
// 计算天数(计价单位数)
|
|
4187
|
+
function days$1({
|
|
4188
|
+
checkin, // 入住时间
|
|
4189
|
+
checkout, // 离开时间
|
|
4190
|
+
method_code = '0', // 计价方法
|
|
4191
|
+
timepoint_hours = 14, // 结算时点
|
|
4192
|
+
timepoint_minutes = 0,
|
|
4193
|
+
timepoint2_hours = 18, // 第二时点
|
|
4194
|
+
timepoint2_minutes = 0
|
|
4195
|
+
}){
|
|
4196
|
+
let count = 0; // 计算天数(计价单位数)
|
|
4197
|
+
|
|
4198
|
+
//时段错误
|
|
4199
|
+
if (checkout <= checkin){
|
|
4200
|
+
return 1; // 至少计价1天(1个计价单位)
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
if (method_code === "0"){ // 日结
|
|
4204
|
+
//结算时点
|
|
4205
|
+
let checkin0 = new Date(checkin.toDateString()),
|
|
4206
|
+
checkout0 = new Date(checkout.toDateString());
|
|
4207
|
+
|
|
4208
|
+
if (checkin0 === checkout0){ // 当日不考虑结算时点
|
|
4209
|
+
return 1;
|
|
4210
|
+
}
|
|
4211
|
+
|
|
4212
|
+
// 天数
|
|
4213
|
+
count = Math.round((checkout0 - checkin0) / (1000 * 60 * 60 * 24));
|
|
4214
|
+
|
|
4215
|
+
// 半天计价
|
|
4216
|
+
if (
|
|
4217
|
+
(
|
|
4218
|
+
(checkout.getHours() > timepoint_hours) ||
|
|
4219
|
+
(
|
|
4220
|
+
checkout.getHours() === timepoint_hours &&
|
|
4221
|
+
checkout.getMinutes() > timepoint_minutes
|
|
4222
|
+
)
|
|
4223
|
+
) && (
|
|
4224
|
+
(checkout.getHours() <= timepoint2_hours) ||
|
|
4225
|
+
(
|
|
4226
|
+
checkout.getHours() === timepoint2_hours &&
|
|
4227
|
+
checkout.getMinutes() <= timepoint2_minutes
|
|
4228
|
+
)
|
|
4229
|
+
)
|
|
4230
|
+
){
|
|
4231
|
+
count = count + 0.5;
|
|
4232
|
+
}else if(
|
|
4233
|
+
(checkout.getHours() > timepoint2_hours) ||
|
|
4234
|
+
(
|
|
4235
|
+
checkout.getHours() === timepoint2_hours &&
|
|
4236
|
+
checkout.getMinutes() > timepoint2_minutes
|
|
4237
|
+
)
|
|
4238
|
+
){
|
|
4239
|
+
count = count + 1;
|
|
4240
|
+
}
|
|
4241
|
+
|
|
4242
|
+
// 至少 1 天
|
|
4243
|
+
count = (count < 1) ? 1 : count;
|
|
4244
|
+
}else if(method_code === "1"){ // 小时
|
|
4245
|
+
count = Math.round((checkout - checkin) / (1000 * 60 * 60)); // 小时数
|
|
4246
|
+
count = (count <= 0) ? 1 : count; // 至少 1 小时
|
|
4247
|
+
}else if(method_code === "2"){ // 月结
|
|
4248
|
+
let c = (checkout.getFullYear() - checkin.getFullYear()) * 12,
|
|
4249
|
+
c0 = (checkout.getMonth() >= checkin.getMonth())
|
|
4250
|
+
? (checkout.getMonth() - checkin.getMonth())
|
|
4251
|
+
: (12 - checkin.getMonth + checkout.getMonth());
|
|
4252
|
+
|
|
4253
|
+
count = c + c0 >= 1 ? c + c0 : 1; // 至少 1 个月
|
|
4254
|
+
}
|
|
4255
|
+
|
|
4256
|
+
return count;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
// 单房计价
|
|
4260
|
+
function calculator({
|
|
4261
|
+
price,
|
|
4262
|
+
checkin, // 入住时间
|
|
4263
|
+
checkout, // 离开时间
|
|
4264
|
+
method_code = '0', // 计价方法
|
|
4265
|
+
timepoint_hours = 14, // 结算时点
|
|
4266
|
+
timepoint_minutes = 0,
|
|
4267
|
+
timepoint2_hours = 18, // 第二时点
|
|
4268
|
+
timepoint2_minutes = 0
|
|
4269
|
+
}){
|
|
4270
|
+
const count = days$1({
|
|
4271
|
+
checkin,
|
|
4272
|
+
checkout,
|
|
4273
|
+
method_code,
|
|
4274
|
+
timepoint_hours,
|
|
4275
|
+
timepoint_minutes,
|
|
4276
|
+
timepoint2_hours,
|
|
4277
|
+
timepoint2_minutes
|
|
4278
|
+
});
|
|
4279
|
+
|
|
4280
|
+
return price * count
|
|
4281
|
+
}
|
|
4282
|
+
|
|
4283
|
+
var calculator$1 = {
|
|
4284
|
+
days: days$1,
|
|
4285
|
+
calculator
|
|
4286
|
+
};
|
|
4287
|
+
|
|
4288
|
+
var ly0d4 = {
|
|
4289
|
+
busicode,
|
|
4290
|
+
calculator: calculator$1
|
|
4291
|
+
};
|
|
4292
|
+
|
|
4178
4293
|
/**
|
|
4179
4294
|
* 将Date对象格式化为指定的字符串格式
|
|
4180
4295
|
*
|
|
@@ -5309,10 +5424,12 @@ var unclassified = {
|
|
|
5309
5424
|
|
|
5310
5425
|
var index = {
|
|
5311
5426
|
GBT,
|
|
5427
|
+
ly0d4,
|
|
5312
5428
|
unclassified
|
|
5313
5429
|
};
|
|
5314
5430
|
|
|
5315
5431
|
exports.GBT = GBT;
|
|
5316
5432
|
exports.default = index;
|
|
5433
|
+
exports.ly0d4 = ly0d4;
|
|
5317
5434
|
exports.unclassified = unclassified;
|
|
5318
5435
|
//# sourceMappingURL=index.cjs.js.map
|