public async Task <IActionResult> CancelOppointmentAsync([FromBody] UpdateOppointmentStatusRequestDto requestDto) { var consumptionBiz = new ConsumptionBiz(); var model = consumptionBiz.GetModel(requestDto.ConsumptionGuid); if (model == null || string.IsNullOrWhiteSpace(model.ConsumptionGuid)) { return(Failed(ErrorCode.Empty, "找不到该预约记录!")); } if (!model.ConsumptionStatus.Equals(ConsumptionStatusEnum.Booked.ToString())) { return(Failed(ErrorCode.UserData, "该预约记录的状态不支持取消,请检查!")); } var projectModel = await new ProjectBiz().GetAsync(model.ProjectGuid); var categoryExtensionModel = await new MerchantCategoryBiz().GetModelByClassifyGuidAsync(projectModel.ClassifyGuid, projectModel.MerchantGuid); var limitTime = (categoryExtensionModel?.LimitTime) ?? 30; if (requestDto.FromPoint == "Consumer") { if (DateTime.Now >= model.AppointmentDate) { return(Failed(ErrorCode.UserData, $"当前已过预约时间,请联系门店处理!")); } else if ((model.AppointmentDate - DateTime.Now).TotalMinutes < limitTime) { return(Failed(ErrorCode.UserData, $"当前离到店服务时间不足{limitTime}分钟,不可取消,请联系门店处理!")); } } model.ConsumptionStatus = ConsumptionStatusEnum.Canceled.ToString(); model.LastUpdatedBy = UserID; model.LastUpdatedDate = DateTime.Now; //取消预约 须在个人产品数量上+1 var goodsItemModel = await new GoodsItemBiz().GetAsync(model.FromItemGuid); if (goodsItemModel == null) { return(Failed(ErrorCode.Empty, "找不到该记录的个人商品项!")); } goodsItemModel.Remain++; goodsItemModel.Used--; goodsItemModel.Available = goodsItemModel.Remain > 0; //删除预约所占时间 var merchantScheduleDetailModel = await new MerchantScheduleDetailBiz().GetModelAsyncByConsumptionGuid(model.ConsumptionGuid); if (merchantScheduleDetailModel == null) { return(Failed(ErrorCode.Empty, "找不到该预约所占用时间!")); } var isSuccess = await consumptionBiz.CancelOppointment(model, goodsItemModel, merchantScheduleDetailModel); return(Success(isSuccess)); }
public async Task <IActionResult> SetMissStautsForConsumptionAsync(string consumptionGuid) { var consumptionBiz = new ConsumptionBiz(); var model = consumptionBiz.GetModel(consumptionGuid); if (model == null) { return(Failed(ErrorCode.Empty, "没找到该预约信息!")); } if (!string.Equals(model.ConsumptionStatus.ToString(), ConsumptionStatusEnum.Booked.ToString(), StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.UserData, "该预约记录不处于[已预约]状态,不能修改状态为[已错过]")); } if (DateTime.Now < model.AppointmentDate) { return(Failed(ErrorCode.UserData, "当前还未到预约的时间,不能修改预约记录状态为[已错过]")); } model.LastUpdatedBy = UserID; model.LastUpdatedDate = DateTime.Now; var result = await consumptionBiz.UpdateAsync(model); return(result ? Success() : Failed(ErrorCode.DataBaseError, "修改预约记录状态为[已错过]失败")); }
public async Task <IActionResult> StartConsumption(string consumptionGuid) { var consumptionBiz = new ConsumptionBiz(); var model = consumptionBiz.GetModel(consumptionGuid); if (model == null) { return(Failed(ErrorCode.Empty, "没找到该预约信息!")); } var checkWorking = await consumptionBiz.CheckHasWorkingConsumptionAsync(model.OperatorGuid); if (checkWorking) { return(Failed(ErrorCode.UserData, "尚有服务正在进行中,请先完成进行中的服务")); } if (!string.Equals(model.ConsumptionStatus.ToString(), ConsumptionStatusEnum.Booked.ToString(), StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.UserData, "该消费记录不处于[已预约]状态,不能执行开始操作")); } var result = ChangeStatus(model, ConsumptionStatusEnum.Arrive); return(result ? Success() : Failed(ErrorCode.DataBaseError, "开始操作失败")); }