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