修复店务预约与小程序生产问题
This commit is contained in:
+3
@@ -34,6 +34,9 @@ public class OrderItemDO extends BaseEntity {
|
||||
private BigDecimal referencePrice;
|
||||
private BigDecimal quotedPrice;
|
||||
private BigDecimal confirmedPrice;
|
||||
private Boolean depositPaid;
|
||||
private Boolean needRemoval;
|
||||
private Boolean fromMeituan;
|
||||
/**
|
||||
* Field `artistId` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
|
||||
*/
|
||||
|
||||
+3
@@ -9,6 +9,9 @@ public class PlanningAppointmentCreateDTO {
|
||||
private Long customerUserId;
|
||||
private String customerName;
|
||||
private String phone;
|
||||
private Boolean depositPaid;
|
||||
private Boolean needRemoval;
|
||||
private Boolean fromMeituan;
|
||||
private Long productId;
|
||||
private Integer quantity;
|
||||
private Long artistId;
|
||||
|
||||
+66
-20
@@ -117,8 +117,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
);
|
||||
Map<LocalDate, ShopScheduleExceptionDO> shopExceptionByDate = listShopScheduleExceptions(shopId, start, end);
|
||||
|
||||
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
|
||||
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artists, artistId);
|
||||
List<PlanningArtistVO> artists = listArtists(shopId, null);
|
||||
List<PlanningArtistVO> selectedArtists = selectCalendarArtists(artists, artistId);
|
||||
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, selectedArtists, artistId);
|
||||
List<PlanningScheduleVO> scheduleVos = schedules.stream()
|
||||
.map(schedule -> toScheduleVO(schedule, artists))
|
||||
.sorted(Comparator.comparing(PlanningScheduleVO::getDate)
|
||||
@@ -141,7 +142,8 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setArtists(artists);
|
||||
vo.setSchedules(scheduleVos);
|
||||
vo.setAppointments(appointments);
|
||||
vo.setDaySummaries(buildDaySummaries(start, end, artists, schedules, appointments, shop, shopExceptionByDate));
|
||||
vo.setDaySummaries(buildDaySummaries(start, end, selectedArtists, schedules, appointments, shop, shopExceptionByDate,
|
||||
artistId != null && artistId > 0));
|
||||
return vo;
|
||||
}
|
||||
|
||||
@@ -195,6 +197,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
item.setPrice(unitPrice);
|
||||
item.setArtistId(artist.getId());
|
||||
item.setAppointmentTime(startTime);
|
||||
item.setDepositPaid(Boolean.TRUE.equals(dto.getDepositPaid()));
|
||||
item.setNeedRemoval(Boolean.TRUE.equals(dto.getNeedRemoval()));
|
||||
item.setFromMeituan(Boolean.TRUE.equals(dto.getFromMeituan()));
|
||||
item.setIsDelete(0);
|
||||
orderItemMapper.insert(item);
|
||||
|
||||
@@ -282,6 +287,15 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
item.setPrice(unitPrice);
|
||||
item.setArtistId(artist.getId());
|
||||
item.setAppointmentTime(startTime);
|
||||
if (dto.getDepositPaid() != null) {
|
||||
item.setDepositPaid(dto.getDepositPaid());
|
||||
}
|
||||
if (dto.getNeedRemoval() != null) {
|
||||
item.setNeedRemoval(dto.getNeedRemoval());
|
||||
}
|
||||
if (dto.getFromMeituan() != null) {
|
||||
item.setFromMeituan(dto.getFromMeituan());
|
||||
}
|
||||
orderItemMapper.updateById(item);
|
||||
return getAppointment(currentUser, item.getId());
|
||||
}
|
||||
@@ -662,6 +676,9 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setArtistId(artistId);
|
||||
vo.setArtistName(artist == null ? "未分配" : artist.getName());
|
||||
vo.setArtistColor(artist == null ? ARTIST_COLORS.get(0) : artist.getColor());
|
||||
vo.setDepositPaid(item != null && Boolean.TRUE.equals(item.getDepositPaid()));
|
||||
vo.setNeedRemoval(item != null && Boolean.TRUE.equals(item.getNeedRemoval()));
|
||||
vo.setFromMeituan(item != null && Boolean.TRUE.equals(item.getFromMeituan()));
|
||||
vo.setDate(start == null ? null : start.toLocalDate().toString());
|
||||
vo.setStartTime(start == null ? null : DATE_TIME_FORMATTER.format(start));
|
||||
vo.setEndTime(end == null ? null : DATE_TIME_FORMATTER.format(end));
|
||||
@@ -681,7 +698,8 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
private List<PlanningDaySummaryVO> buildDaySummaries(LocalDate start, LocalDate end, List<PlanningArtistVO> artists,
|
||||
List<ArtistScheduleDO> schedules, List<PlanningAppointmentVO> appointments,
|
||||
ShopDO shop, Map<LocalDate, ShopScheduleExceptionDO> shopExceptionByDate) {
|
||||
ShopDO shop, Map<LocalDate, ShopScheduleExceptionDO> shopExceptionByDate,
|
||||
boolean artistScoped) {
|
||||
Map<String, List<PlanningAppointmentVO>> appointmentsByDate = appointments.stream()
|
||||
.filter(appointment -> appointment.getDate() != null)
|
||||
.collect(Collectors.groupingBy(PlanningAppointmentVO::getDate));
|
||||
@@ -737,15 +755,30 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
ShopScheduleSupport.LocalTimeRange openRange = ShopScheduleSupport.resolveOpenRange(shop, shopExceptionByDate.get(cursor), cursor);
|
||||
summary.setBusinessStartTime(openRange.startTime() == null ? null : openRange.startTime().toString());
|
||||
summary.setBusinessEndTime(openRange.endTime() == null ? null : openRange.endTime().toString());
|
||||
summary.setDayStatus(openRange.open()
|
||||
? PlanningCalendarSupport.resolveDayStatus(total, hasWorkingSchedule, allFull)
|
||||
: "rest");
|
||||
summary.setDayStatus(resolveDaySummaryStatus(openRange, total, hasWorkingSchedule, allFull, artistScoped));
|
||||
summaries.add(summary);
|
||||
cursor = cursor.plusDays(1);
|
||||
}
|
||||
return summaries;
|
||||
}
|
||||
|
||||
private String resolveDaySummaryStatus(ShopScheduleSupport.LocalTimeRange openRange, int totalCount,
|
||||
boolean hasWorkingSchedule, boolean allFull, boolean artistScoped) {
|
||||
if (!openRange.open()) {
|
||||
return "rest";
|
||||
}
|
||||
if (artistScoped) {
|
||||
return PlanningCalendarSupport.resolveDayStatus(totalCount, hasWorkingSchedule, allFull);
|
||||
}
|
||||
if (hasWorkingSchedule && allFull) {
|
||||
return "full";
|
||||
}
|
||||
if (totalCount <= 0) {
|
||||
return "free";
|
||||
}
|
||||
return "working";
|
||||
}
|
||||
|
||||
private Map<LocalDate, ShopScheduleExceptionDO> listShopScheduleExceptions(Long shopId, LocalDate start, LocalDate end) {
|
||||
return shopScheduleExceptionMapper.selectList(new QueryWrapper<ShopScheduleExceptionDO>()
|
||||
.eq("shop_id", shopId)
|
||||
@@ -884,23 +917,27 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
}
|
||||
return customer;
|
||||
}
|
||||
if (!hasText(dto.getPhone())) {
|
||||
throw new RuntimeException("客户手机号不能为空");
|
||||
String customerName = trimToNull(dto.getCustomerName());
|
||||
String phone = trimToNull(dto.getPhone());
|
||||
if (hasText(phone)) {
|
||||
QueryWrapper<UserDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_delete", 0)
|
||||
.and(query -> query.eq("phone", phone).or().eq("contact_phone", phone))
|
||||
.last("LIMIT 1");
|
||||
UserDO existing = userMapper.selectOne(wrapper);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
}
|
||||
}
|
||||
QueryWrapper<UserDO> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("is_delete", 0)
|
||||
.and(query -> query.eq("phone", dto.getPhone()).or().eq("contact_phone", dto.getPhone()))
|
||||
.last("LIMIT 1");
|
||||
UserDO existing = userMapper.selectOne(wrapper);
|
||||
if (existing != null) {
|
||||
return existing;
|
||||
if (!hasText(customerName)) {
|
||||
throw new RuntimeException("客户姓名不能为空");
|
||||
}
|
||||
UserDO customer = new UserDO();
|
||||
customer.setShopId(shopId);
|
||||
customer.setNickname(firstNonBlank(dto.getCustomerName(), dto.getPhone()));
|
||||
customer.setPhone(dto.getPhone());
|
||||
customer.setContactPhone(dto.getPhone());
|
||||
customer.setAccount(dto.getPhone());
|
||||
customer.setNickname(firstNonBlank(customerName, phone, "到店客户"));
|
||||
customer.setPhone(phone);
|
||||
customer.setContactPhone(phone);
|
||||
customer.setAccount("guest" + snowflakeIdGenerator.nextIdString());
|
||||
customer.setPassword(ENCODED_UNSET_PASSWORD);
|
||||
customer.setType(0);
|
||||
customer.setStatus(1);
|
||||
@@ -909,6 +946,15 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
return customer;
|
||||
}
|
||||
|
||||
private List<PlanningArtistVO> selectCalendarArtists(List<PlanningArtistVO> artists, Long artistId) {
|
||||
if (artistId == null || artistId <= 0) {
|
||||
return artists;
|
||||
}
|
||||
return artists.stream()
|
||||
.filter(artist -> Objects.equals(artist.getId(), artistId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private String buildOrderCustomerNameSnapshot(PlanningAppointmentCreateDTO dto, UserDO customer) {
|
||||
return firstNonBlank(
|
||||
dto.getCustomerName(),
|
||||
|
||||
+3
@@ -25,6 +25,9 @@ public class PlanningAppointmentVO {
|
||||
private Integer status;
|
||||
private String statusText;
|
||||
private String occupancyStatus;
|
||||
private Boolean depositPaid;
|
||||
private Boolean needRemoval;
|
||||
private Boolean fromMeituan;
|
||||
private Boolean canEdit;
|
||||
private Boolean canCancel;
|
||||
private String conflictReason;
|
||||
|
||||
Reference in New Issue
Block a user