优化员工排班与规划月视图体验
This commit is contained in:
-2
@@ -13,7 +13,5 @@ public class ArtistScheduleExceptionDTO {
|
||||
private String exceptionType;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private String remark;
|
||||
}
|
||||
|
||||
-2
@@ -13,8 +13,6 @@ public class ArtistScheduleRuleDTO {
|
||||
private List<Integer> workDays;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
}
|
||||
|
||||
+15
@@ -99,4 +99,19 @@ public class NailArtistInfoDTO {
|
||||
* 用户签名
|
||||
*/
|
||||
private String signature;
|
||||
|
||||
/**
|
||||
* 头像访问地址
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 排班模式摘要
|
||||
*/
|
||||
private String scheduleModeSummary;
|
||||
|
||||
/**
|
||||
* 排班时间摘要
|
||||
*/
|
||||
private String scheduleTimeSummary;
|
||||
}
|
||||
|
||||
+4
-12
@@ -168,8 +168,8 @@ public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
||||
rule.setWorkDays(encodeWorkDays(resolveWorkDays(dto.getWorkDays(), presetType)));
|
||||
rule.setStartTime(startTime);
|
||||
rule.setEndTime(endTime);
|
||||
rule.setSlotMinutes(normalizeSlotMinutes(dto.getSlotMinutes()));
|
||||
rule.setCapacity(normalizeCapacity(dto.getCapacity()));
|
||||
rule.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
||||
rule.setCapacity(DEFAULT_CAPACITY);
|
||||
rule.setStatus(dto.getStatus() == null ? 1 : dto.getStatus());
|
||||
rule.setRemark(trimText(dto.getRemark()));
|
||||
rule.setIsDelete(0);
|
||||
@@ -196,8 +196,8 @@ public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
||||
exception.setExceptionType(exceptionType);
|
||||
exception.setStartTime(startTime);
|
||||
exception.setEndTime(endTime);
|
||||
exception.setSlotMinutes(normalizeSlotMinutes(dto.getSlotMinutes()));
|
||||
exception.setCapacity(normalizeCapacity(dto.getCapacity()));
|
||||
exception.setSlotMinutes(DEFAULT_SLOT_MINUTES);
|
||||
exception.setCapacity(DEFAULT_CAPACITY);
|
||||
exception.setRemark(trimText(dto.getRemark()));
|
||||
exception.setIsDelete(0);
|
||||
return exception;
|
||||
@@ -406,14 +406,6 @@ public class ArtistScheduleServiceImpl implements ArtistScheduleService {
|
||||
}
|
||||
}
|
||||
|
||||
private Integer normalizeSlotMinutes(Integer slotMinutes) {
|
||||
return slotMinutes == null || slotMinutes < 15 ? DEFAULT_SLOT_MINUTES : slotMinutes;
|
||||
}
|
||||
|
||||
private Integer normalizeCapacity(Integer capacity) {
|
||||
return capacity == null || capacity < 1 ? DEFAULT_CAPACITY : capacity;
|
||||
}
|
||||
|
||||
private String trimText(String value) {
|
||||
return value == null ? null : value.trim();
|
||||
}
|
||||
|
||||
+71
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.dto.NailArtistInfoDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.entity.ArtistScheduleRuleDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderDO;
|
||||
@@ -14,6 +15,7 @@ import com.xiaowang.fingertipdesigner.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.ArtistScheduleRuleMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderMapper;
|
||||
@@ -66,6 +68,8 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
private static final int MAX_AVAILABILITY_SLOTS = 16;
|
||||
private static final DateTimeFormatter DATE_TEXT_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
private static final DateTimeFormatter TIME_TEXT_FORMATTER = DateTimeFormatter.ofPattern("HH:mm");
|
||||
private static final String PRESET_DOUBLE_REST = "DOUBLE_REST";
|
||||
private static final String PRESET_SINGLE_REST = "SINGLE_REST";
|
||||
|
||||
@Autowired
|
||||
/**
|
||||
@@ -109,6 +113,9 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleRuleMapper artistScheduleRuleMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
@@ -143,6 +150,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
result.add(dto);
|
||||
}
|
||||
}
|
||||
enrichScheduleSummaries(result, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -177,6 +185,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
dto.setShopName(shop == null ? null : shop.getShopName());
|
||||
result.add(dto);
|
||||
}
|
||||
enrichScheduleSummaries(result, shopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -405,6 +414,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
if (user != null) {
|
||||
dto.setNickname(user.getNickname());
|
||||
dto.setSignature(user.getSignature());
|
||||
dto.setAvatar(resolveAccessibleAvatar(user.getAvatar()));
|
||||
dto.setUserType(user.getType());
|
||||
dto.setUserTypeName(resolveUserTypeName(user.getType()));
|
||||
if (dto.getParticipateProduction() == null) {
|
||||
@@ -432,6 +442,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
dto.setUserId(user.getId());
|
||||
dto.setNickname(user.getNickname());
|
||||
dto.setSignature(user.getSignature());
|
||||
dto.setAvatar(resolveAccessibleAvatar(user.getAvatar()));
|
||||
dto.setUserType(user.getType());
|
||||
dto.setUserTypeName(resolveUserTypeName(user.getType()));
|
||||
dto.setIdentity("美甲师");
|
||||
@@ -453,6 +464,66 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return dto;
|
||||
}
|
||||
|
||||
private void enrichScheduleSummaries(List<NailArtistInfoDTO> artists, Long shopId) {
|
||||
if (artistScheduleRuleMapper == null || artists == null || artists.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Set<Long> artistIds = artists.stream()
|
||||
.map(NailArtistInfoDTO::getUserId)
|
||||
.filter(userId -> userId != null && userId > 0)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
if (artistIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
LambdaQueryWrapper<ArtistScheduleRuleDO> wrapper = new LambdaQueryWrapper<ArtistScheduleRuleDO>()
|
||||
.in(ArtistScheduleRuleDO::getArtistId, artistIds)
|
||||
.eq(ArtistScheduleRuleDO::getIsDelete, 0);
|
||||
if (shopId != null && shopId > 0) {
|
||||
wrapper.eq(ArtistScheduleRuleDO::getShopId, shopId);
|
||||
}
|
||||
Map<Long, ArtistScheduleRuleDO> ruleByArtistId = artistScheduleRuleMapper.selectList(wrapper).stream()
|
||||
.collect(Collectors.toMap(ArtistScheduleRuleDO::getArtistId, rule -> rule, (left, right) -> left));
|
||||
artists.forEach(artist -> applyScheduleSummary(artist, ruleByArtistId.get(artist.getUserId())));
|
||||
}
|
||||
|
||||
private void applyScheduleSummary(NailArtistInfoDTO artist, ArtistScheduleRuleDO rule) {
|
||||
if (artist == null) {
|
||||
return;
|
||||
}
|
||||
if (rule == null || !Integer.valueOf(1).equals(rule.getStatus())) {
|
||||
artist.setScheduleModeSummary("未设置");
|
||||
artist.setScheduleTimeSummary("");
|
||||
return;
|
||||
}
|
||||
artist.setScheduleModeSummary(resolveScheduleModeSummary(rule.getPresetType()));
|
||||
artist.setScheduleTimeSummary(formatScheduleTimeSummary(rule.getStartTime(), rule.getEndTime()));
|
||||
}
|
||||
|
||||
private String resolveScheduleModeSummary(String presetType) {
|
||||
if (PRESET_DOUBLE_REST.equals(presetType)) {
|
||||
return "双休";
|
||||
}
|
||||
if (PRESET_SINGLE_REST.equals(presetType)) {
|
||||
return "单休";
|
||||
}
|
||||
return "自定义";
|
||||
}
|
||||
|
||||
private String formatScheduleTimeSummary(LocalTime startTime, LocalTime endTime) {
|
||||
if (startTime == null || endTime == null) {
|
||||
return "";
|
||||
}
|
||||
return TIME_TEXT_FORMATTER.format(startTime) + "-" + TIME_TEXT_FORMATTER.format(endTime);
|
||||
}
|
||||
|
||||
private String resolveAccessibleAvatar(String avatar) {
|
||||
if (!StringUtils.hasText(avatar)) {
|
||||
return null;
|
||||
}
|
||||
String accessibleUrl = objectStorageUrlSupport.toAccessibleUrl(avatar);
|
||||
return StringUtils.hasText(accessibleUrl) ? accessibleUrl : avatar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `isVisibleServiceUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
-2
@@ -15,8 +15,6 @@ public class ArtistScheduleExceptionVO {
|
||||
private String exceptionType;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private String remark;
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
-2
@@ -15,8 +15,6 @@ public class ArtistScheduleRuleVO {
|
||||
private List<Integer> workDays;
|
||||
private LocalTime startTime;
|
||||
private LocalTime endTime;
|
||||
private Integer slotMinutes;
|
||||
private Integer capacity;
|
||||
private Integer status;
|
||||
private String remark;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
+55
-13
@@ -63,6 +63,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
private static final int DEFAULT_SLOT_MINUTES = 30;
|
||||
private static final int DEFAULT_DURATION_MINUTES = 60;
|
||||
private static final int MONTH_AVAILABLE_MINUTES = 90;
|
||||
private static final String RESERVATION_PENDING_QUOTE = "PENDING_QUOTE";
|
||||
private static final String RESERVATION_CONFIRMED = "CONFIRMED";
|
||||
private static final String PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT = "MANAGER_APPOINTMENT";
|
||||
@@ -525,15 +526,18 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
List<PlanningArtistCountVO> artistCounts = new ArrayList<>();
|
||||
int workingArtistCount = 0;
|
||||
int busyWorkingArtistCount = 0;
|
||||
int fullWorkingArtistCount = 0;
|
||||
for (PlanningArtistVO artist : artists) {
|
||||
int count = countByArtist.getOrDefault(artist.getId(), 0L).intValue();
|
||||
ArtistScheduleDO schedule = scheduleByArtist.get(artist.getId());
|
||||
String artistStatus = resolveArtistDayStatus(artist, schedule, count);
|
||||
List<PlanningAppointmentVO> artistAppointments = dayAppointments.stream()
|
||||
.filter(appointment -> Objects.equals(appointment.getArtistId(), artist.getId()))
|
||||
.toList();
|
||||
String artistStatus = resolveArtistDayStatus(artist, schedule, artistAppointments);
|
||||
if (!"rest".equals(artistStatus)) {
|
||||
workingArtistCount++;
|
||||
if (count > 0) {
|
||||
busyWorkingArtistCount++;
|
||||
if ("full".equals(artistStatus)) {
|
||||
fullWorkingArtistCount++;
|
||||
}
|
||||
}
|
||||
PlanningArtistCountVO countVO = new PlanningArtistCountVO();
|
||||
@@ -547,33 +551,71 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
}
|
||||
int total = dayAppointments.size();
|
||||
boolean hasWorkingSchedule = workingArtistCount > 0;
|
||||
boolean allBusy = workingArtistCount > 0 && busyWorkingArtistCount == workingArtistCount;
|
||||
boolean allFull = workingArtistCount > 0 && fullWorkingArtistCount == workingArtistCount;
|
||||
|
||||
PlanningDaySummaryVO summary = new PlanningDaySummaryVO();
|
||||
summary.setDate(date);
|
||||
summary.setTotalCount(total);
|
||||
summary.setArtistCounts(artistCounts);
|
||||
summary.setDayStatus(PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allBusy));
|
||||
summary.setDayStatus(PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull));
|
||||
summaries.add(summary);
|
||||
cursor = cursor.plusDays(1);
|
||||
}
|
||||
return summaries;
|
||||
}
|
||||
|
||||
private String resolveArtistDayStatus(PlanningArtistVO artist, ArtistScheduleDO schedule, int count) {
|
||||
private String resolveArtistDayStatus(PlanningArtistVO artist, ArtistScheduleDO schedule, List<PlanningAppointmentVO> appointments) {
|
||||
if (schedule != null && !Integer.valueOf(1).equals(schedule.getStatus())) {
|
||||
return "rest";
|
||||
}
|
||||
if (schedule == null && Integer.valueOf(0).equals(artist.getStatus())) {
|
||||
if (schedule == null || Integer.valueOf(0).equals(artist.getStatus())) {
|
||||
return "rest";
|
||||
}
|
||||
if (count <= 0) {
|
||||
return "free";
|
||||
if (hasContinuousFreeWindow(schedule, appointments, MONTH_AVAILABLE_MINUTES)) {
|
||||
return appointments.isEmpty() ? "free" : "working";
|
||||
}
|
||||
if (schedule != null && schedule.getCapacity() != null && schedule.getCapacity() > 0 && count >= schedule.getCapacity() * 4) {
|
||||
return "full";
|
||||
return "full";
|
||||
}
|
||||
|
||||
private boolean hasContinuousFreeWindow(ArtistScheduleDO schedule, List<PlanningAppointmentVO> appointments, int requiredMinutes) {
|
||||
if (schedule == null || schedule.getStartTime() == null || schedule.getEndTime() == null || requiredMinutes <= 0) {
|
||||
return false;
|
||||
}
|
||||
return "working";
|
||||
int startMinute = schedule.getStartTime().toSecondOfDay() / 60;
|
||||
int endMinute = schedule.getEndTime().toSecondOfDay() / 60;
|
||||
if (endMinute - startMinute < requiredMinutes) {
|
||||
return false;
|
||||
}
|
||||
int cursor = startMinute;
|
||||
List<TimeRange> ranges = appointments.stream()
|
||||
.map(this::toTimeRange)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(range -> range.endMinute() > startMinute && range.startMinute() < endMinute)
|
||||
.map(range -> new TimeRange(Math.max(range.startMinute(), startMinute), Math.min(range.endMinute(), endMinute)))
|
||||
.sorted(Comparator.comparing(TimeRange::startMinute).thenComparing(TimeRange::endMinute))
|
||||
.toList();
|
||||
for (TimeRange range : ranges) {
|
||||
if (range.startMinute() - cursor >= requiredMinutes) {
|
||||
return true;
|
||||
}
|
||||
cursor = Math.max(cursor, range.endMinute());
|
||||
}
|
||||
return endMinute - cursor >= requiredMinutes;
|
||||
}
|
||||
|
||||
private TimeRange toTimeRange(PlanningAppointmentVO appointment) {
|
||||
if (appointment == null) {
|
||||
return null;
|
||||
}
|
||||
Integer startMinute = appointment.getStartMinute();
|
||||
Integer durationMinutes = appointment.getDurationMinutes();
|
||||
if (startMinute == null || durationMinutes == null || durationMinutes <= 0) {
|
||||
return null;
|
||||
}
|
||||
return new TimeRange(startMinute, startMinute + durationMinutes);
|
||||
}
|
||||
|
||||
private record TimeRange(int startMinute, int endMinute) {
|
||||
}
|
||||
|
||||
private ProductDO requireActiveProduct(Long productId, Long shopId) {
|
||||
|
||||
+3
-3
@@ -69,12 +69,12 @@ public final class PlanningCalendarSupport {
|
||||
if (!hasWorkingSchedule) {
|
||||
return "rest";
|
||||
}
|
||||
if (totalCount <= 0) {
|
||||
return "free";
|
||||
}
|
||||
if (allWorkingArtistsBusy) {
|
||||
return "full";
|
||||
}
|
||||
if (totalCount <= 0) {
|
||||
return "free";
|
||||
}
|
||||
return "working";
|
||||
}
|
||||
|
||||
|
||||
+12
-5
@@ -107,7 +107,18 @@ class ArtistScheduleServiceImplTest {
|
||||
|
||||
service.saveException(extraWorkException(sunday));
|
||||
|
||||
verify(scheduleMapper).updateGeneratedSchedule(any(), eq(LocalTime.of(10, 0)), eq(LocalTime.of(18, 0)), eq(30), eq(2), eq(1), any());
|
||||
verify(scheduleMapper).updateGeneratedSchedule(any(), eq(LocalTime.of(10, 0)), eq(LocalTime.of(18, 0)), eq(60), eq(1), eq(1), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveRuleUsesInternalCapacityAndSlotDefaults() {
|
||||
service.saveRule(rule("DOUBLE_REST", List.of(1, 2, 3, 4, 5), LocalTime.of(9, 0), LocalTime.of(17, 0)));
|
||||
|
||||
ArgumentCaptor<Integer> slotCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
ArgumentCaptor<Integer> capacityCaptor = ArgumentCaptor.forClass(Integer.class);
|
||||
verify(scheduleMapper, org.mockito.Mockito.atLeastOnce()).updateGeneratedSchedule(any(), any(), any(), slotCaptor.capture(), capacityCaptor.capture(), any(), any());
|
||||
assertThat(slotCaptor.getAllValues()).allMatch(value -> value == 60);
|
||||
assertThat(capacityCaptor.getAllValues()).allMatch(value -> value == 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,8 +149,6 @@ class ArtistScheduleServiceImplTest {
|
||||
dto.setWorkDays(workDays);
|
||||
dto.setStartTime(startTime);
|
||||
dto.setEndTime(endTime);
|
||||
dto.setSlotMinutes(60);
|
||||
dto.setCapacity(1);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -160,8 +169,6 @@ class ArtistScheduleServiceImplTest {
|
||||
dto.setExceptionType("EXTRA_WORK");
|
||||
dto.setStartTime(LocalTime.of(10, 0));
|
||||
dto.setEndTime(LocalTime.of(18, 0));
|
||||
dto.setSlotMinutes(30);
|
||||
dto.setCapacity(2);
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
+108
@@ -2,6 +2,7 @@ package com.xiaowang.fingertipdesigner.core.modules.planning.service.impl;
|
||||
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderItemMapper;
|
||||
@@ -27,7 +28,9 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -184,6 +187,49 @@ class PlanningServiceImplTest {
|
||||
assertThat(product.getImageFileIds()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void calendarMarksMonthAvailabilityByContinuousNinetyMinuteWindow() {
|
||||
UserDO manager = user(2, 8L);
|
||||
UserDO freeArtist = user(3, 8L);
|
||||
freeArtist.setId(20L);
|
||||
freeArtist.setNickname("小王");
|
||||
UserDO shortShiftArtist = user(3, 8L);
|
||||
shortShiftArtist.setId(21L);
|
||||
shortShiftArtist.setNickname("小李");
|
||||
LocalDate date = LocalDate.of(2026, 6, 26);
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setBusinessHours("09:00-18:00");
|
||||
ArtistScheduleDO freeSchedule = schedule(20L, date, LocalTime.of(9, 0), LocalTime.of(12, 0));
|
||||
ArtistScheduleDO shortSchedule = schedule(21L, date, LocalTime.of(9, 0), LocalTime.of(10, 0));
|
||||
AppointmentReservationDO reservation = reservation(20L, 200L, 300L, date.atTime(10, 30), date.atTime(12, 0));
|
||||
OrderDO order = order(200L, 8L, 30L);
|
||||
OrderItemDO item = orderItem(300L, 200L, 100L, 20L, date.atTime(10, 30));
|
||||
ProductDO product = product(100L, 8L, "90分钟");
|
||||
UserDO customer = user(0, 8L);
|
||||
customer.setId(30L);
|
||||
customer.setNickname("测试客户");
|
||||
|
||||
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
|
||||
when(shopMapper.selectById(8L)).thenReturn(shop);
|
||||
when(userMapper.selectList(any())).thenReturn(List.of(freeArtist, shortShiftArtist));
|
||||
when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of());
|
||||
when(artistScheduleMapper.selectList(any())).thenReturn(List.of(freeSchedule, shortSchedule));
|
||||
when(appointmentReservationMapper.selectList(any())).thenReturn(List.of(reservation));
|
||||
when(orderItemMapper.selectList(any())).thenReturn(List.of());
|
||||
when(orderItemMapper.selectBatchIds(any())).thenReturn(List.of(item));
|
||||
when(orderMapper.selectBatchIds(any())).thenReturn(List.of(order));
|
||||
when(productMapper.selectBatchIds(any())).thenReturn(List.of(product));
|
||||
when(userMapper.selectBatchIds(any())).thenReturn(List.of(customer));
|
||||
|
||||
var calendar = planningService.getCalendar(manager, date, date, null);
|
||||
|
||||
var summary = calendar.getDaySummaries().get(0);
|
||||
assertThat(summary.getDayStatus()).isEqualTo("working");
|
||||
assertThat(summary.getArtistCounts())
|
||||
.extracting(count -> count.getArtistId() + ":" + count.getStatus())
|
||||
.contains("20:working", "21:full");
|
||||
}
|
||||
|
||||
private UserDO user(Integer type, Long shopId) {
|
||||
UserDO user = new UserDO();
|
||||
user.setId(10L + type);
|
||||
@@ -194,4 +240,66 @@ class PlanningServiceImplTest {
|
||||
user.setPhone("13800138000");
|
||||
return user;
|
||||
}
|
||||
|
||||
private ArtistScheduleDO schedule(Long artistId, LocalDate date, LocalTime startTime, LocalTime endTime) {
|
||||
ArtistScheduleDO schedule = new ArtistScheduleDO();
|
||||
schedule.setId(1000L + artistId);
|
||||
schedule.setShopId(8L);
|
||||
schedule.setArtistId(artistId);
|
||||
schedule.setWorkDate(date);
|
||||
schedule.setStartTime(startTime);
|
||||
schedule.setEndTime(endTime);
|
||||
schedule.setCapacity(1);
|
||||
schedule.setSlotMinutes(90);
|
||||
schedule.setStatus(1);
|
||||
schedule.setIsDelete(0);
|
||||
return schedule;
|
||||
}
|
||||
|
||||
private AppointmentReservationDO reservation(Long artistId, Long orderId, Long orderItemId,
|
||||
LocalDateTime startTime, LocalDateTime endTime) {
|
||||
AppointmentReservationDO reservation = new AppointmentReservationDO();
|
||||
reservation.setOrderId(orderId);
|
||||
reservation.setOrderItemId(orderItemId);
|
||||
reservation.setShopId(8L);
|
||||
reservation.setArtistId(artistId);
|
||||
reservation.setProductTitle("测试预约");
|
||||
reservation.setAppointmentStartTime(startTime);
|
||||
reservation.setAppointmentEndTime(endTime);
|
||||
reservation.setStatus("CONFIRMED");
|
||||
reservation.setIsDelete(0);
|
||||
return reservation;
|
||||
}
|
||||
|
||||
private OrderDO order(Long orderId, Long shopId, Long customerId) {
|
||||
OrderDO order = new OrderDO();
|
||||
order.setId(orderId);
|
||||
order.setShopId(shopId);
|
||||
order.setUserId(customerId);
|
||||
order.setStatus(1);
|
||||
order.setIsDelete(0);
|
||||
return order;
|
||||
}
|
||||
|
||||
private OrderItemDO orderItem(Long orderItemId, Long orderId, Long productId, Long artistId, LocalDateTime appointmentTime) {
|
||||
OrderItemDO item = new OrderItemDO();
|
||||
item.setId(orderItemId);
|
||||
item.setOrderId(orderId);
|
||||
item.setProductId(productId);
|
||||
item.setArtistId(artistId);
|
||||
item.setQuantity(1);
|
||||
item.setAppointmentTime(appointmentTime);
|
||||
item.setIsDelete(0);
|
||||
return item;
|
||||
}
|
||||
|
||||
private ProductDO product(Long productId, Long shopId, String durationText) {
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(productId);
|
||||
product.setShopId(shopId);
|
||||
product.setTitle("测试作品");
|
||||
product.setApproximateDuration(durationText);
|
||||
product.setIsDelete(0);
|
||||
return product;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user