321
This commit is contained in:
parent
507f05d2fd
commit
6749e1e882
|
|
@ -1,4 +1,4 @@
|
|||
/***********************************************************************
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.ViewModels.SQ;
|
||||
using System;
|
||||
|
|
@ -56,6 +56,12 @@ namespace CoreCms.Net.IServices
|
|||
/// <param name="dto">节假日定价DTO</param>
|
||||
/// <returns>是否成功</returns>
|
||||
Task<bool> SetHolidayPricingAsync(SetHolidayPricingDto dto);
|
||||
|
||||
Task<List<SQRoomPricing>> GetHolidayPricingByDateAsync(int roomId, DateTime date);
|
||||
|
||||
Task<bool> DeleteHolidayPricingAsync(int roomId, DateTime date);
|
||||
|
||||
Task<bool> HasHolidayPricingAsync(int roomId, DateTime date);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,6 +242,64 @@ namespace CoreCms.Net.Services
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询某房间某日期的节假日价格列表
|
||||
/// </summary>
|
||||
public async Task<List<SQRoomPricing>> GetHolidayPricingByDateAsync(int roomId, DateTime date)
|
||||
{
|
||||
var queryDate = date.Date;
|
||||
|
||||
// 查询该日期的节假日价格(有日期范围的价格配置)
|
||||
var holidayPricing = await _pricingRepository.QueryListByClauseAsync(
|
||||
p => p.room_id == roomId &&
|
||||
p.effective_date_start != null &&
|
||||
p.effective_date_end != null &&
|
||||
p.effective_date_start <= queryDate &&
|
||||
p.effective_date_end >= queryDate &&
|
||||
p.is_active == true,
|
||||
p => p.time_slot_type,
|
||||
OrderByType.Asc
|
||||
);
|
||||
|
||||
return holidayPricing ?? new List<SQRoomPricing>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除某房间某日期的节假日价格
|
||||
/// </summary>
|
||||
public async Task<bool> DeleteHolidayPricingAsync(int roomId, DateTime date)
|
||||
{
|
||||
try
|
||||
{
|
||||
var queryDate = date.Date;
|
||||
|
||||
// 查询该日期的节假日价格
|
||||
var holidayPricing = await GetHolidayPricingByDateAsync(roomId, queryDate);
|
||||
|
||||
if (holidayPricing == null || holidayPricing.Count == 0)
|
||||
{
|
||||
return true; // 没有数据,直接返回成功
|
||||
}
|
||||
|
||||
// 删除所有节假日价格记录
|
||||
var ids = holidayPricing.Select(p => p.id).ToArray();
|
||||
return await _pricingRepository.DeleteByIdsAsync(ids);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查某房间某日期是否设置了节假日价格
|
||||
/// </summary>
|
||||
public async Task<bool> HasHolidayPricingAsync(int roomId, DateTime date)
|
||||
{
|
||||
var holidayPricing = await GetHolidayPricingByDateAsync(roomId, date);
|
||||
return holidayPricing != null && holidayPricing.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/***********************************************************************
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
|
|
@ -1564,6 +1564,306 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region 节假日价格管理============================================================
|
||||
// GET: Api/SQRoomPricing/GetHolidayPricing
|
||||
/// <summary>
|
||||
/// 获取某日期的节假日价格(用于弹窗回显)
|
||||
/// </summary>
|
||||
/// <param name="date">日期</param>
|
||||
/// <param name="roomId">房间ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Description("获取节假日价格")]
|
||||
public async Task<AdminUiCallBack> GetHolidayPricing([FromQuery] string date, [FromQuery] int roomId)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
// 参数验证
|
||||
if (roomId <= 0)
|
||||
{
|
||||
jm.msg = "请选择房间";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(date))
|
||||
{
|
||||
jm.msg = "请选择日期";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(date, out DateTime dateValue))
|
||||
{
|
||||
jm.msg = "日期格式不正确";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 检查房间是否存在
|
||||
var room = await _SQRoomsServices.QueryByIdAsync(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
jm.msg = "房间不存在";
|
||||
return jm;
|
||||
}
|
||||
|
||||
// 查询节假日价格
|
||||
var holidayPricing = await _SQRoomPricingServices.GetHolidayPricingByDateAsync(roomId, dateValue);
|
||||
|
||||
// 查询默认价格(用于对比)
|
||||
var defaultPricing = await _SQRoomPricingServices.GetRoomAllPricingAsync(roomId, null);
|
||||
|
||||
// 时段名称映射
|
||||
var slotNames = new[] { "凌晨", "上午", "下午", "晚上" };
|
||||
|
||||
// 构建返回数据(包含所有4个时段)
|
||||
var result = new List<object>();
|
||||
for (int slotType = 0; slotType <= 3; slotType++)
|
||||
{
|
||||
var holidaySlot = holidayPricing.FirstOrDefault(p => p.time_slot_type == slotType);
|
||||
var defaultSlot = defaultPricing.FirstOrDefault(p => p.time_slot_type == slotType);
|
||||
|
||||
result.Add(new
|
||||
{
|
||||
time_slot_type = slotType,
|
||||
slot_name = slotNames[slotType],
|
||||
has_holiday_price = holidaySlot != null,
|
||||
// 节假日价格描述
|
||||
holiday_price_desc_standard = holidaySlot?.price_desc_standard ?? "",
|
||||
holiday_price_desc_member = holidaySlot?.price_desc_member ?? "",
|
||||
// 默认价格描述(用于前端显示对比)
|
||||
default_price_desc_standard = defaultSlot?.price_desc_standard ?? "",
|
||||
default_price_desc_member = defaultSlot?.price_desc_member ?? ""
|
||||
});
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "获取成功";
|
||||
jm.data = new
|
||||
{
|
||||
date = date,
|
||||
room_id = roomId,
|
||||
room_name = room.name,
|
||||
slots = result
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
jm.msg = "获取失败:" + ex.Message;
|
||||
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "获取节假日价格", "GetHolidayPricing", ex);
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
// POST: Api/SQRoomPricing/DoSetHolidayPricing
|
||||
/// <summary>
|
||||
/// 设置节假日价格(保存)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("设置节假日价格")]
|
||||
public async Task<AdminUiCallBack> DoSetHolidayPricing([FromBody] SetHolidayPricingRequest request)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
// 参数验证
|
||||
if (string.IsNullOrEmpty(request.date))
|
||||
{
|
||||
jm.msg = "请选择日期";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(request.date, out DateTime dateValue))
|
||||
{
|
||||
jm.msg = "日期格式不正确";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (request.roomIds == null || request.roomIds.Length == 0)
|
||||
{
|
||||
jm.msg = "请选择房间";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (request.slots == null || request.slots.Length == 0)
|
||||
{
|
||||
jm.msg = "请至少启用一个时段";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var successCount = 0;
|
||||
var errorMsg = "";
|
||||
|
||||
// 遍历房间
|
||||
foreach (var roomId in request.roomIds)
|
||||
{
|
||||
// 检查房间是否存在
|
||||
var room = await _SQRoomsServices.QueryByIdAsync(roomId);
|
||||
if (room == null)
|
||||
{
|
||||
errorMsg = $"房间ID {roomId} 不存在";
|
||||
continue;
|
||||
}
|
||||
|
||||
// 先删除该房间该日期已有的节假日价格
|
||||
await _SQRoomPricingServices.DeleteHolidayPricingAsync(roomId, dateValue);
|
||||
|
||||
// 保存新的节假日价格
|
||||
foreach (var slot in request.slots)
|
||||
{
|
||||
if (!slot.enabled)
|
||||
{
|
||||
continue; // 未启用的时段不保存
|
||||
}
|
||||
|
||||
var pricing = new SQRoomPricing
|
||||
{
|
||||
room_id = roomId,
|
||||
time_slot_type = slot.time_slot_type,
|
||||
standard_price = 0, // 不使用此字段,但数据库要求非空,设为0
|
||||
member_price = 0, // 不使用此字段,但数据库要求非空,设为0
|
||||
price_desc_standard = slot.price_desc_standard,
|
||||
price_desc_member = slot.price_desc_member,
|
||||
effective_date_start = dateValue.Date,
|
||||
effective_date_end = dateValue.Date,
|
||||
is_active = true,
|
||||
created_at = DateTime.Now,
|
||||
updated_at = DateTime.Now
|
||||
};
|
||||
|
||||
await _SQRoomPricingServices.InsertAsync(pricing);
|
||||
}
|
||||
|
||||
successCount++;
|
||||
}
|
||||
|
||||
if (successCount > 0)
|
||||
{
|
||||
jm.code = 0;
|
||||
jm.msg = $"设置成功,共设置 {successCount} 个房间的节假日价格";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = errorMsg ?? "设置失败";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
jm.msg = "设置失败:" + ex.Message;
|
||||
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "设置节假日价格", "DoSetHolidayPricing", ex);
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
// POST: Api/SQRoomPricing/DoCancelHolidayPricing
|
||||
/// <summary>
|
||||
/// 取消节假日价格(删除该日期的特殊价格)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("取消节假日价格")]
|
||||
public async Task<AdminUiCallBack> DoCancelHolidayPricing([FromBody] CancelHolidayPricingRequest request)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
// 参数验证
|
||||
if (string.IsNullOrEmpty(request.date))
|
||||
{
|
||||
jm.msg = "请选择日期";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(request.date, out DateTime dateValue))
|
||||
{
|
||||
jm.msg = "日期格式不正确";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (request.roomIds == null || request.roomIds.Length == 0)
|
||||
{
|
||||
jm.msg = "请选择房间";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var successCount = 0;
|
||||
|
||||
// 遍历房间,删除节假日价格
|
||||
foreach (var roomId in request.roomIds)
|
||||
{
|
||||
var result = await _SQRoomPricingServices.DeleteHolidayPricingAsync(roomId, dateValue);
|
||||
if (result)
|
||||
{
|
||||
successCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0)
|
||||
{
|
||||
jm.code = 0;
|
||||
jm.msg = $"取消成功,共取消 {successCount} 个房间的节假日价格";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = "取消失败或该日期没有节假日价格";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
jm.msg = "取消失败:" + ex.Message;
|
||||
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "取消节假日价格", "DoCancelHolidayPricing", ex);
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
// GET: Api/SQRoomPricing/HasHolidayPricing
|
||||
/// <summary>
|
||||
/// 查询某日期是否设置了节假日价格(用于右键菜单显示)
|
||||
/// </summary>
|
||||
/// <param name="date">日期</param>
|
||||
/// <param name="roomId">房间ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Description("检查是否有节假日价格")]
|
||||
public async Task<AdminUiCallBack> HasHolidayPricing([FromQuery] string date, [FromQuery] int roomId)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
try
|
||||
{
|
||||
if (roomId <= 0 || string.IsNullOrEmpty(date))
|
||||
{
|
||||
jm.msg = "参数错误";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (!DateTime.TryParse(date, out DateTime dateValue))
|
||||
{
|
||||
jm.msg = "日期格式不正确";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var hasHolidayPrice = await _SQRoomPricingServices.HasHolidayPricingAsync(roomId, dateValue);
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "查询成功";
|
||||
jm.data = new { has_holiday_price = hasHolidayPrice };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
jm.msg = "查询失败:" + ex.Message;
|
||||
NLogUtil.WriteAll(LogLevel.Error, LogType.Web, "检查节假日价格", "HasHolidayPricing", ex);
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1641,5 +1941,68 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
|||
/// </summary>
|
||||
public string date { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置节假日价格请求参数
|
||||
/// </summary>
|
||||
public class SetHolidayPricingRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期 (YYYY-MM-DD)
|
||||
/// </summary>
|
||||
public string date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 房间ID数组
|
||||
/// </summary>
|
||||
public int[] roomIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时段价格列表
|
||||
/// </summary>
|
||||
public HolidaySlotPrice[] slots { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 节假日时段价格
|
||||
/// </summary>
|
||||
public class HolidaySlotPrice
|
||||
{
|
||||
/// <summary>
|
||||
/// 时段类型(0=凌晨,1=上午,2=下午,3=晚上)
|
||||
/// </summary>
|
||||
public int time_slot_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用该时段节假日价格
|
||||
/// </summary>
|
||||
public bool enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 标准价格描述(文本,如:"150元/时段")
|
||||
/// </summary>
|
||||
public string price_desc_standard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 会员价格描述(文本,如:"120元/时段")
|
||||
/// </summary>
|
||||
public string price_desc_member { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消节假日价格请求参数
|
||||
/// </summary>
|
||||
public class CancelHolidayPricingRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 日期 (YYYY-MM-DD)
|
||||
/// </summary>
|
||||
public string date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 房间ID数组
|
||||
/// </summary>
|
||||
public int[] roomIds { get; set; }
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4167,6 +4167,34 @@
|
|||
<param name="date">日期</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.SQRoomPricingController.GetHolidayPricing(System.String,System.Int32)">
|
||||
<summary>
|
||||
获取某日期的节假日价格(用于弹窗回显)
|
||||
</summary>
|
||||
<param name="date">日期</param>
|
||||
<param name="roomId">房间ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.SQRoomPricingController.DoSetHolidayPricing(CoreCms.Net.Web.Admin.Controllers.SetHolidayPricingRequest)">
|
||||
<summary>
|
||||
设置节假日价格(保存)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.SQRoomPricingController.DoCancelHolidayPricing(CoreCms.Net.Web.Admin.Controllers.CancelHolidayPricingRequest)">
|
||||
<summary>
|
||||
取消节假日价格(删除该日期的特殊价格)
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.SQRoomPricingController.HasHolidayPricing(System.String,System.Int32)">
|
||||
<summary>
|
||||
查询某日期是否设置了节假日价格(用于右键菜单显示)
|
||||
</summary>
|
||||
<param name="date">日期</param>
|
||||
<param name="roomId">房间ID</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:CoreCms.Net.Web.Admin.Controllers.SetRoomUnavailableRequest">
|
||||
<summary>
|
||||
设置房间不可用请求参数
|
||||
|
|
@ -4237,6 +4265,66 @@
|
|||
日期 (YYYY-MM-DD)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:CoreCms.Net.Web.Admin.Controllers.SetHolidayPricingRequest">
|
||||
<summary>
|
||||
设置节假日价格请求参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.SetHolidayPricingRequest.date">
|
||||
<summary>
|
||||
日期 (YYYY-MM-DD)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.SetHolidayPricingRequest.roomIds">
|
||||
<summary>
|
||||
房间ID数组
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.SetHolidayPricingRequest.slots">
|
||||
<summary>
|
||||
时段价格列表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:CoreCms.Net.Web.Admin.Controllers.HolidaySlotPrice">
|
||||
<summary>
|
||||
节假日时段价格
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.HolidaySlotPrice.time_slot_type">
|
||||
<summary>
|
||||
时段类型(0=凌晨,1=上午,2=下午,3=晚上)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.HolidaySlotPrice.enabled">
|
||||
<summary>
|
||||
是否启用该时段节假日价格
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.HolidaySlotPrice.price_desc_standard">
|
||||
<summary>
|
||||
标准价格描述(文本,如:"150元/时段")
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.HolidaySlotPrice.price_desc_member">
|
||||
<summary>
|
||||
会员价格描述(文本,如:"120元/时段")
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:CoreCms.Net.Web.Admin.Controllers.CancelHolidayPricingRequest">
|
||||
<summary>
|
||||
取消节假日价格请求参数
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.CancelHolidayPricingRequest.date">
|
||||
<summary>
|
||||
日期 (YYYY-MM-DD)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:CoreCms.Net.Web.Admin.Controllers.CancelHolidayPricingRequest.roomIds">
|
||||
<summary>
|
||||
房间ID数组
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:CoreCms.Net.Web.Admin.Controllers.SQRoomsController">
|
||||
<summary>
|
||||
房间表
|
||||
|
|
|
|||
|
|
@ -0,0 +1,280 @@
|
|||
<script type="text/html" template lay-done="layui.data.sendParams(d);">
|
||||
<div class="layui-form" lay-filter="setHolidayPriceForm" style="padding: 20px;">
|
||||
<!-- 日期和房间合并一行 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">日期</label>
|
||||
<div class="layui-input-inline" style="width: 200px;">
|
||||
<input type="text" class="layui-input" value="{{d.params.data.dateStr || ''}}" readonly>
|
||||
</div>
|
||||
<label class="layui-form-label" style="margin-left: 20px;">房间</label>
|
||||
<div class="layui-input-inline" style="width: 200px;">
|
||||
<input type="text" class="layui-input" value="{{d.params.data.roomName || ''}}" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 应用到所有房间选项 -->
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">应用范围</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="applyToAllRooms" lay-skin="primary" title="应用到所有房间" lay-filter="applyToAllRooms">
|
||||
<div class="layui-form-mid layui-word-aux" style="margin-left: 10px;">勾选后将为所有房间设置相同的节假日价格</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 提示信息 -->
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
<blockquote class="layui-elem-quote layui-quote-nm" style="border-left-color: #ff9800;">
|
||||
<i class="layui-icon layui-icon-tips" style="color: #ff9800;"></i>
|
||||
未启用的时段将使用普通价格,已启用的时段将覆盖当天的普通价格
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时段价格列表 -->
|
||||
<div class="time-slot-list" style="margin-top: 20px;">
|
||||
<!-- 凌晨时段 -->
|
||||
<div class="time-slot-item" data-slot="0" style="border: 1px solid #e6e6e6; border-radius: 4px; padding: 15px; margin-bottom: 15px; background: #fff;">
|
||||
<div class="layui-form-item" style="margin-bottom: 10px;">
|
||||
<label class="layui-form-label" style="width: 80px;">凌晨:</label>
|
||||
<div class="layui-input-block" style="margin-left: 90px; display: flex; align-items: center; flex-wrap: wrap;">
|
||||
<input type="checkbox" name="switch_0" lay-skin="switch" lay-text="启用|关闭" lay-filter="slot-switch">
|
||||
<div style="margin-left: 20px; flex: 1; min-width: 500px;">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">普通价格描述:</span>
|
||||
<input type="text" name="price_desc_standard_0" placeholder="例如:150元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">会员价格描述:</span>
|
||||
<input type="text" name="price_desc_member_0" placeholder="例如:120元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="color: #999; font-size: 12px;" id="default_price_0">
|
||||
(默认: 普通 <span class="default-standard">-</span> / 会员 <span class="default-member">-</span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 上午时段 -->
|
||||
<div class="time-slot-item" data-slot="1" style="border: 1px solid #e6e6e6; border-radius: 4px; padding: 15px; margin-bottom: 15px; background: #fff;">
|
||||
<div class="layui-form-item" style="margin-bottom: 10px;">
|
||||
<label class="layui-form-label" style="width: 80px;">上午:</label>
|
||||
<div class="layui-input-block" style="margin-left: 90px; display: flex; align-items: center; flex-wrap: wrap;">
|
||||
<input type="checkbox" name="switch_1" lay-skin="switch" lay-text="启用|关闭" lay-filter="slot-switch">
|
||||
<div style="margin-left: 20px; flex: 1; min-width: 500px;">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">普通价格描述:</span>
|
||||
<input type="text" name="price_desc_standard_1" placeholder="例如:200元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">会员价格描述:</span>
|
||||
<input type="text" name="price_desc_member_1" placeholder="例如:180元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="color: #999; font-size: 12px;" id="default_price_1">
|
||||
(默认: 普通 <span class="default-standard">-</span> / 会员 <span class="default-member">-</span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 下午时段 -->
|
||||
<div class="time-slot-item" data-slot="2" style="border: 1px solid #e6e6e6; border-radius: 4px; padding: 15px; margin-bottom: 15px; background: #fff;">
|
||||
<div class="layui-form-item" style="margin-bottom: 10px;">
|
||||
<label class="layui-form-label" style="width: 80px;">下午:</label>
|
||||
<div class="layui-input-block" style="margin-left: 90px; display: flex; align-items: center; flex-wrap: wrap;">
|
||||
<input type="checkbox" name="switch_2" lay-skin="switch" lay-text="启用|关闭" lay-filter="slot-switch">
|
||||
<div style="margin-left: 20px; flex: 1; min-width: 500px;">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">普通价格描述:</span>
|
||||
<input type="text" name="price_desc_standard_2" placeholder="例如:200元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">会员价格描述:</span>
|
||||
<input type="text" name="price_desc_member_2" placeholder="例如:180元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="color: #999; font-size: 12px;" id="default_price_2">
|
||||
(默认: 普通 <span class="default-standard">-</span> / 会员 <span class="default-member">-</span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 晚上时段 -->
|
||||
<div class="time-slot-item" data-slot="3" style="border: 1px solid #e6e6e6; border-radius: 4px; padding: 15px; margin-bottom: 15px; background: #fff;">
|
||||
<div class="layui-form-item" style="margin-bottom: 10px;">
|
||||
<label class="layui-form-label" style="width: 80px;">晚上:</label>
|
||||
<div class="layui-input-block" style="margin-left: 90px; display: flex; align-items: center; flex-wrap: wrap;">
|
||||
<input type="checkbox" name="switch_3" lay-skin="switch" lay-text="启用|关闭" lay-filter="slot-switch">
|
||||
<div style="margin-left: 20px; flex: 1; min-width: 500px;">
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">普通价格描述:</span>
|
||||
<input type="text" name="price_desc_standard_3" placeholder="例如:250元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="margin-bottom: 10px;">
|
||||
<span style="margin-right: 5px;">会员价格描述:</span>
|
||||
<input type="text" name="price_desc_member_3" placeholder="例如:220元/时段" class="layui-input" style="width: 200px; display: inline-block;" disabled>
|
||||
</div>
|
||||
<div style="color: #999; font-size: 12px;" id="default_price_3">
|
||||
(默认: 普通 <span class="default-standard">-</span> / 会员 <span class="default-member">-</span>)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var debug = layui.setter.debug;
|
||||
layui.data.sendParams = function (d) {
|
||||
//开启调试情况下获取接口赋值数据
|
||||
if (debug) { console.log(d.params.data); }
|
||||
layui.use(['admin', 'form', 'element', 'coreHelper', 'layer'],
|
||||
function () {
|
||||
var $ = layui.$
|
||||
, form = layui.form
|
||||
, element = layui.element
|
||||
, admin = layui.admin
|
||||
, coreHelper = layui.coreHelper
|
||||
, layer = layui.layer;
|
||||
|
||||
var params = d.params.data;
|
||||
var dateStr = params.dateStr;
|
||||
var selectedRoomId = params.selectedRoomId;
|
||||
var roomOptions = params.roomOptions;
|
||||
var refreshSingleDay = params.refreshSingleDay; // 刷新单个日期的函数
|
||||
|
||||
// 切换时段表单元素的启用/禁用状态
|
||||
function toggleSlotForm(slotType, enabled) {
|
||||
var slotItem = $('.time-slot-item[data-slot="' + slotType + '"]');
|
||||
var standardInput = slotItem.find('input[name="price_desc_standard_' + slotType + '"]');
|
||||
var memberInput = slotItem.find('input[name="price_desc_member_' + slotType + '"]');
|
||||
|
||||
if (enabled) {
|
||||
standardInput.prop('disabled', false);
|
||||
memberInput.prop('disabled', false);
|
||||
slotItem.css('background', '#fffbe6'); // 启用时高亮背景
|
||||
} else {
|
||||
standardInput.prop('disabled', true);
|
||||
memberInput.prop('disabled', true);
|
||||
slotItem.css('background', '#fff');
|
||||
}
|
||||
}
|
||||
|
||||
// 开关切换事件
|
||||
form.on('switch(slot-switch)', function(data) {
|
||||
var slotType = parseInt(data.elem.name.replace('switch_', ''));
|
||||
var isChecked = data.elem.checked;
|
||||
toggleSlotForm(slotType, isChecked);
|
||||
});
|
||||
|
||||
// 加载该日期的节假日价格
|
||||
coreHelper.Get("Api/SQRoomPricing/GetHolidayPricing?roomId=" + selectedRoomId + "&date=" + encodeURIComponent(dateStr), function(e) {
|
||||
if (e.code === 0 && e.data && e.data.slots) {
|
||||
// 遍历所有时段,填充数据
|
||||
layui.each(e.data.slots, function(index, slot) {
|
||||
var slotType = slot.time_slot_type;
|
||||
var slotItem = $('.time-slot-item[data-slot="' + slotType + '"]');
|
||||
|
||||
// 显示默认价格描述
|
||||
slotItem.find('#default_price_' + slotType + ' .default-standard').text(slot.default_price_desc_standard || '-');
|
||||
slotItem.find('#default_price_' + slotType + ' .default-member').text(slot.default_price_desc_member || '-');
|
||||
|
||||
if (slot.has_holiday_price) {
|
||||
// 已有节假日价格,回显
|
||||
slotItem.find('input[name="switch_' + slotType + '"]').prop('checked', true);
|
||||
slotItem.find('input[name="price_desc_standard_' + slotType + '"]').val(slot.holiday_price_desc_standard || '');
|
||||
slotItem.find('input[name="price_desc_member_' + slotType + '"]').val(slot.holiday_price_desc_member || '');
|
||||
toggleSlotForm(slotType, true);
|
||||
} else {
|
||||
// 没有节假日价格,使用默认价格描述
|
||||
slotItem.find('input[name="switch_' + slotType + '"]').prop('checked', false);
|
||||
slotItem.find('input[name="price_desc_standard_' + slotType + '"]').val(slot.default_price_desc_standard || '');
|
||||
slotItem.find('input[name="price_desc_member_' + slotType + '"]').val(slot.default_price_desc_member || '');
|
||||
toggleSlotForm(slotType, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//重载form
|
||||
form.render('checkbox', 'setHolidayPriceForm');
|
||||
});
|
||||
|
||||
// 保存提交处理函数到全局,供弹窗的确定按钮调用
|
||||
window._setHolidayPriceSubmitHandler = function(layero, index) {
|
||||
var applyToAllRooms = layero.find('input[name="applyToAllRooms"]').prop('checked');
|
||||
var slots = [];
|
||||
var hasEnabledSlot = false;
|
||||
|
||||
// 收集所有时段的价格描述数据
|
||||
for (var slotType = 0; slotType <= 3; slotType++) {
|
||||
var switchChecked = layero.find('input[name="switch_' + slotType + '"]').prop('checked');
|
||||
var priceDescStandard = (layero.find('input[name="price_desc_standard_' + slotType + '"]').val() || '').trim();
|
||||
var priceDescMember = (layero.find('input[name="price_desc_member_' + slotType + '"]').val() || '').trim();
|
||||
|
||||
if (switchChecked) {
|
||||
hasEnabledSlot = true;
|
||||
|
||||
// 验证价格描述
|
||||
if (!priceDescStandard || !priceDescMember) {
|
||||
layer.msg('请输入价格描述(不能为空)');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
slots.push({
|
||||
time_slot_type: slotType,
|
||||
enabled: switchChecked,
|
||||
price_desc_standard: priceDescStandard,
|
||||
price_desc_member: priceDescMember
|
||||
});
|
||||
}
|
||||
|
||||
if (!hasEnabledSlot) {
|
||||
layer.msg('请至少启用一个时段的节假日价格');
|
||||
return;
|
||||
}
|
||||
|
||||
// 确定要设置的房间ID列表
|
||||
var roomIds = [];
|
||||
if (applyToAllRooms) {
|
||||
// 应用到所有房间
|
||||
if (roomOptions && roomOptions.length > 0) {
|
||||
roomIds = roomOptions.map(function(r) { return r.id; });
|
||||
} else {
|
||||
layer.msg('无可用房间');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 只应用到当前房间
|
||||
roomIds = [selectedRoomId];
|
||||
}
|
||||
|
||||
// 显示加载提示
|
||||
var loadIndex = layer.load(1, {shade: [0.1,'#fff']});
|
||||
|
||||
// 调用保存接口
|
||||
coreHelper.Post("Api/SQRoomPricing/DoSetHolidayPricing", {
|
||||
date: dateStr,
|
||||
roomIds: roomIds,
|
||||
slots: slots
|
||||
}, function(e) {
|
||||
layer.close(loadIndex);
|
||||
if (e.code === 0) {
|
||||
layer.close(index);
|
||||
layer.msg(e.msg);
|
||||
// 刷新当前日期
|
||||
if (refreshSingleDay && typeof refreshSingleDay === 'function') {
|
||||
refreshSingleDay(dateStr);
|
||||
}
|
||||
} else {
|
||||
layer.msg(e.msg || '设置失败');
|
||||
}
|
||||
});
|
||||
};
|
||||
})
|
||||
};
|
||||
</script>
|
||||
|
|
@ -82,11 +82,32 @@
|
|||
background: #f0fffe;
|
||||
}
|
||||
|
||||
/* 有节假日价格的日期标识 */
|
||||
.calendar-day.has-holiday-price {
|
||||
border-color: #ff9800;
|
||||
background: #fff8e1;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.calendar-day.has-holiday-price .calendar-day-header::after {
|
||||
content: "节";
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
background: #ff9800;
|
||||
color: #fff;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.calendar-day-header {
|
||||
font-weight: bold;
|
||||
margin-bottom: 8px;
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.calendar-day-price {
|
||||
|
|
@ -810,6 +831,12 @@
|
|||
case 'view':
|
||||
showDateDetails(dateStr);
|
||||
break;
|
||||
case 'setHolidayPrice':
|
||||
showSetHolidayPriceDialog(dateStr);
|
||||
break;
|
||||
case 'cancelHolidayPrice':
|
||||
showCancelHolidayPriceConfirm(dateStr);
|
||||
break;
|
||||
case 'setUnavailable':
|
||||
showSetUnavailableDialog(dateStr);
|
||||
break;
|
||||
|
|
@ -830,6 +857,15 @@
|
|||
icon: "fa-eye"
|
||||
},
|
||||
"sep1": "---------",
|
||||
"setHolidayPrice": {
|
||||
name: "设置节假日价格",
|
||||
icon: "fa-calendar-plus-o"
|
||||
},
|
||||
"cancelHolidayPrice": {
|
||||
name: "取消节假日价格",
|
||||
icon: "fa-calendar-minus-o"
|
||||
},
|
||||
"sep2": "---------",
|
||||
"setUnavailable": {
|
||||
name: "设置预约状态",
|
||||
icon: "fa-ban"
|
||||
|
|
@ -838,7 +874,7 @@
|
|||
name: "取消预约状态",
|
||||
icon: "fa-check-circle"
|
||||
},
|
||||
"sep2": "---------",
|
||||
"sep3": "---------",
|
||||
"disableAllDay": {
|
||||
name: "禁用整天",
|
||||
icon: "fa-calendar-times"
|
||||
|
|
@ -883,6 +919,93 @@
|
|||
});
|
||||
}
|
||||
|
||||
// 设置节假日价格弹窗
|
||||
function showSetHolidayPriceDialog(dateStr) {
|
||||
if (!selectedRoomId) {
|
||||
layer.msg('请先选择房间');
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedRoom = roomOptions.find(function (r) {
|
||||
return r.id == selectedRoomId;
|
||||
});
|
||||
var roomName = selectedRoom ? selectedRoom.name : '未知房间';
|
||||
|
||||
admin.popup({
|
||||
shadeClose: false,
|
||||
title: '设置节假日价格 - ' + roomName + ' - ' + dateStr,
|
||||
area: ['1200px', '800px'],
|
||||
id: 'LAY-popup-SQRoomPricing-holiday-price',
|
||||
btn: ['确定', '取消'],
|
||||
success: function (layero, index) {
|
||||
view(this.id).render('sq/sqroompricing/holiday-price', {
|
||||
data: {
|
||||
dateStr: dateStr,
|
||||
roomName: roomName,
|
||||
selectedRoomId: selectedRoomId,
|
||||
roomOptions: roomOptions,
|
||||
refreshSingleDay: refreshSingleDay
|
||||
}
|
||||
}).done(function () {
|
||||
form.render('checkbox', 'setHolidayPriceForm');
|
||||
});
|
||||
},
|
||||
yes: function (index, layero) {
|
||||
// 调用模板中保存的提交处理函数
|
||||
if (typeof window._setHolidayPriceSubmitHandler === 'function') {
|
||||
window._setHolidayPriceSubmitHandler(layero, index);
|
||||
} else {
|
||||
layer.msg('提交处理函数未初始化');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 取消节假日价格确认
|
||||
function showCancelHolidayPriceConfirm(dateStr) {
|
||||
if (!selectedRoomId) {
|
||||
layer.msg('请先选择房间');
|
||||
return;
|
||||
}
|
||||
|
||||
var selectedRoom = roomOptions.find(function (r) {
|
||||
return r.id == selectedRoomId;
|
||||
});
|
||||
var roomName = selectedRoom ? selectedRoom.name : '未知房间';
|
||||
|
||||
// 先检查是否设置了节假日价格
|
||||
coreHelper.Get("Api/SQRoomPricing/HasHolidayPricing?roomId=" + selectedRoomId + "&date=" + encodeURIComponent(dateStr), function (e) {
|
||||
if (e.code === 0 && e.data) {
|
||||
if (!e.data.has_holiday_price) {
|
||||
layer.msg('该日期没有设置节假日价格');
|
||||
return;
|
||||
}
|
||||
|
||||
// 确认取消
|
||||
layer.confirm('确定要取消 ' + roomName + ' 在 ' + dateStr + ' 的节假日价格吗?<br>取消后将使用普通价格。', {
|
||||
icon: 3,
|
||||
title: '取消节假日价格确认'
|
||||
}, function (confirmIndex) {
|
||||
// 调用取消节假日价格接口
|
||||
coreHelper.Post("Api/SQRoomPricing/DoCancelHolidayPricing", {
|
||||
date: dateStr,
|
||||
roomIds: [selectedRoomId]
|
||||
}, function (e) {
|
||||
layer.close(confirmIndex);
|
||||
if (e.code === 0) {
|
||||
layer.msg(e.msg);
|
||||
refreshSingleDay(dateStr); // 只刷新当前日期
|
||||
} else {
|
||||
layer.msg(e.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
layer.msg(e.msg || '查询失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 禁用整天确认
|
||||
function showDisableAllDayConfirm(dateStr) {
|
||||
if (!selectedRoomId) {
|
||||
|
|
@ -1058,26 +1181,44 @@
|
|||
// 显示加载中
|
||||
dayElement.append('<div style="text-align:center;color:#999;padding:10px 0;">加载中...</div>');
|
||||
|
||||
coreHelper.Get("Api/SQRoomPricing/GetRoomListWithSlots?date=" + encodeURIComponent(dateStr) + "&showOnlyAvailable=false", function (e) {
|
||||
// 同时加载房间数据和节假日价格标识
|
||||
$.when(
|
||||
$.Deferred(function(dfd) {
|
||||
coreHelper.Get("Api/SQRoomPricing/GetRoomListWithSlots?date=" + encodeURIComponent(dateStr) + "&showOnlyAvailable=false", function(e) {
|
||||
dfd.resolve(e);
|
||||
});
|
||||
}),
|
||||
$.Deferred(function(dfd) {
|
||||
coreHelper.Get("Api/SQRoomPricing/HasHolidayPricing?roomId=" + selectedRoomId + "&date=" + encodeURIComponent(dateStr), function(e) {
|
||||
dfd.resolve(e);
|
||||
});
|
||||
})
|
||||
).done(function(roomResult, holidayResult) {
|
||||
// 再次清空内容(包括加载提示)
|
||||
dayElement.find('div:not(.calendar-day-header)').remove();
|
||||
|
||||
if (e.code === 0 && e.data && Array.isArray(e.data)) {
|
||||
// 注意:roomId 可能是字符串,需要类型转换比较
|
||||
var roomData = e.data.find(function (r) {
|
||||
// 移除旧的节假日标识
|
||||
dayElement.removeClass('has-holiday-price');
|
||||
|
||||
// 添加节假日标识
|
||||
if (holidayResult.code === 0 && holidayResult.data && holidayResult.data.has_holiday_price) {
|
||||
dayElement.addClass('has-holiday-price');
|
||||
}
|
||||
|
||||
// 渲染房间数据
|
||||
if (roomResult.code === 0 && roomResult.data && Array.isArray(roomResult.data)) {
|
||||
var roomData = roomResult.data.find(function (r) {
|
||||
return r.id == selectedRoomId || r.id == parseInt(selectedRoomId);
|
||||
});
|
||||
|
||||
// 使用统一的模板渲染函数
|
||||
var dayContentHtml = renderDayContent(roomData, null);
|
||||
dayElement.append(dayContentHtml);
|
||||
} else {
|
||||
var errorMsg = e.msg || '加载失败';
|
||||
var errorMsg = roomResult.msg || '加载失败';
|
||||
var errorHtml = renderDayContent(null, errorMsg);
|
||||
dayElement.append(errorHtml);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 加载月度数据
|
||||
|
|
@ -1103,9 +1244,21 @@
|
|||
console.log('请求日期:', dateStr);
|
||||
}
|
||||
|
||||
coreHelper.Get("Api/SQRoomPricing/GetRoomListWithSlots?date=" + encodeURIComponent(dateStr) + "&showOnlyAvailable=false", function (e) {
|
||||
// 同时加载房间数据和节假日价格标识
|
||||
$.when(
|
||||
$.Deferred(function(dfd) {
|
||||
coreHelper.Get("Api/SQRoomPricing/GetRoomListWithSlots?date=" + encodeURIComponent(dateStr) + "&showOnlyAvailable=false", function(e) {
|
||||
dfd.resolve(e);
|
||||
});
|
||||
}),
|
||||
$.Deferred(function(dfd) {
|
||||
coreHelper.Get("Api/SQRoomPricing/HasHolidayPricing?roomId=" + roomId + "&date=" + encodeURIComponent(dateStr), function(e) {
|
||||
dfd.resolve(e);
|
||||
});
|
||||
})
|
||||
).done(function(roomResult, holidayResult) {
|
||||
if (debug) {
|
||||
console.log('日期:', dateStr, '返回数据:', e);
|
||||
console.log('日期:', dateStr, '房间数据:', roomResult, '节假日:', holidayResult);
|
||||
}
|
||||
|
||||
var dayElement = $('#calendarGrid').find('.calendar-day[data-date="' + dateStr + '"]');
|
||||
|
|
@ -1122,9 +1275,17 @@
|
|||
// 清空加载提示(保留日期标题)
|
||||
dayElement.find('div:not(.calendar-day-header)').remove();
|
||||
|
||||
if (e.code === 0 && e.data && Array.isArray(e.data)) {
|
||||
// 注意:roomId 可能是字符串,需要类型转换比较
|
||||
var roomData = e.data.find(function (r) {
|
||||
// 移除旧的节假日标识
|
||||
dayElement.removeClass('has-holiday-price');
|
||||
|
||||
// 添加节假日标识
|
||||
if (holidayResult.code === 0 && holidayResult.data && holidayResult.data.has_holiday_price) {
|
||||
dayElement.addClass('has-holiday-price');
|
||||
}
|
||||
|
||||
// 渲染房间数据
|
||||
if (roomResult.code === 0 && roomResult.data && Array.isArray(roomResult.data)) {
|
||||
var roomData = roomResult.data.find(function (r) {
|
||||
return r.id == roomId || r.id == parseInt(roomId);
|
||||
});
|
||||
|
||||
|
|
@ -1132,16 +1293,14 @@
|
|||
console.log('查找房间:', roomId, '找到:', roomData ? '是' : '否');
|
||||
}
|
||||
|
||||
// 使用统一的模板渲染函数
|
||||
var dayContentHtml = renderDayContent(roomData, null);
|
||||
dayElement.append(dayContentHtml);
|
||||
} else {
|
||||
var errorMsg = e.msg || '加载失败';
|
||||
var errorMsg = roomResult.msg || '加载失败';
|
||||
var errorHtml = renderDayContent(null, errorMsg);
|
||||
dayElement.append(errorHtml);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user