优化店务预约作品快照与图片维护

This commit is contained in:
2026-07-21 16:26:56 +08:00
parent 7415b6b451
commit 1c6dabe7d9
20 changed files with 873 additions and 161 deletions
@@ -17,6 +17,7 @@ import com.xiaowang.jayucloud.core.modules.artist.vo.ArtistScheduleVO;
import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerCreateDTO;
import com.xiaowang.jayucloud.core.modules.manager.dto.ManagerCustomerUpdateDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO;
@@ -112,9 +113,20 @@ public class AdminManagerController {
@PathVariable Long orderItemId,
@RequestBody PlanningAppointmentMoveDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
requireManagerOperator(currentUser);
return Result.success(planningService.moveAppointment(currentUser, orderItemId, dto));
}
@PutMapping("/planning/appointments/{orderItemId}/images")
@RequirePermission("order:process")
@OperationGuard(action = "manager-planning-update-appointment-images", ttlSeconds = 10, message = "预约图片保存处理中,请勿重复提交")
public Result<PlanningAppointmentVO> updateAppointmentImages(HttpServletRequest request,
@PathVariable Long orderItemId,
@RequestBody PlanningAppointmentImageDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(planningService.updateAppointmentImages(currentUser, orderItemId, dto));
}
@PutMapping("/planning/appointments/{orderId}/status")
@RequirePermission("order:process")
@OperationGuard(action = "manager-planning-update-appointment-status", ttlSeconds = 10, message = "预约状态处理中,请勿重复提交")
@@ -432,6 +444,13 @@ public class AdminManagerController {
}
}
private void requireManagerOperator(UserDO currentUser) {
if (Integer.valueOf(2).equals(currentUser.getType())) {
return;
}
throw new RuntimeException("只有店长可以改派预约");
}
private boolean hasEmployeeUserBasicChanges(NailArtistInfoDTO dto) {
return dto.getNickname() != null
|| dto.getAvatar() != null
@@ -37,6 +37,11 @@ public class OrderItemDO extends BaseEntity {
private Boolean depositPaid;
private Boolean needRemoval;
private Boolean fromMeituan;
private String appointmentProductTitle;
private String appointmentProductDescription;
private String appointmentProductTags;
private String appointmentProductPrecautions;
private String appointmentProductImageFileIds;
/**
* Field `artistId` (Long): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
*/
@@ -79,6 +79,7 @@ public class AdminPlanningController {
@PathVariable Long orderItemId,
@RequestBody PlanningAppointmentMoveDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
requireManagerOperator(currentUser);
return Result.success(planningService.moveAppointment(currentUser, orderItemId, dto));
}
@@ -91,4 +92,11 @@ public class AdminPlanningController {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(planningService.updateStatus(currentUser, orderId, dto));
}
private void requireManagerOperator(UserDO currentUser) {
if (Integer.valueOf(2).equals(currentUser.getType())) {
return;
}
throw new RuntimeException("只有店长可以改派预约");
}
}
@@ -0,0 +1,8 @@
package com.xiaowang.jayucloud.core.modules.planning.dto;
import lombok.Data;
@Data
public class PlanningAppointmentImageDTO {
private String imageFileIds;
}
@@ -1,6 +1,7 @@
package com.xiaowang.jayucloud.core.modules.planning.service;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO;
@@ -21,5 +22,7 @@ public interface PlanningService {
PlanningAppointmentVO moveAppointment(UserDO currentUser, Long orderItemId, PlanningAppointmentMoveDTO dto);
PlanningAppointmentVO updateAppointmentImages(UserDO currentUser, Long orderItemId, PlanningAppointmentImageDTO dto);
Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto);
}
@@ -2,6 +2,7 @@ package com.xiaowang.jayucloud.core.modules.planning.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO;
@@ -10,6 +11,9 @@ import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleException
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleDO;
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleRuleDO;
import com.xiaowang.jayucloud.core.modules.artist.entity.NailArtistInfoDO;
import com.xiaowang.jayucloud.core.modules.file.service.ObjectStorageFileService;
import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
import com.xiaowang.jayucloud.core.modules.order.entity.OrderItemDO;
import com.xiaowang.jayucloud.core.modules.product.entity.ProductDO;
@@ -57,6 +61,7 @@ import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -75,7 +80,6 @@ public class PlanningServiceImpl implements PlanningService {
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";
private static final String ENCODED_UNSET_PASSWORD = "$2a$10$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW";
private static final List<String> ACTIVE_RESERVATION_STATUS = List.of("LOCKED", RESERVATION_PENDING_QUOTE, RESERVATION_CONFIRMED);
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@@ -93,6 +97,8 @@ public class PlanningServiceImpl implements PlanningService {
private final OrderMapper orderMapper;
private final OrderItemMapper orderItemMapper;
private final ProductMapper productMapper;
private final ObjectStorageFileService objectStorageFileService;
private final ObjectStorageUrlSupport objectStorageUrlSupport;
private final ShopMapper shopMapper;
private final ShopScheduleExceptionMapper shopScheduleExceptionMapper;
private final AppointmentCapacityService appointmentCapacityService;
@@ -192,7 +198,7 @@ public class PlanningServiceImpl implements PlanningService {
OrderItemDO item = new OrderItemDO();
item.setOrderId(order.getId());
item.setProductId(product.getId());
item.setProductId(product == null ? null : product.getId());
item.setQuantity(quantity);
item.setPrice(unitPrice);
item.setArtistId(artist.getId());
@@ -200,6 +206,7 @@ public class PlanningServiceImpl implements PlanningService {
item.setDepositPaid(Boolean.TRUE.equals(dto.getDepositPaid()));
item.setNeedRemoval(Boolean.TRUE.equals(dto.getNeedRemoval()));
item.setFromMeituan(Boolean.TRUE.equals(dto.getFromMeituan()));
applyAppointmentProductSnapshot(item, product, dto);
item.setIsDelete(0);
orderItemMapper.insert(item);
@@ -208,7 +215,7 @@ public class PlanningServiceImpl implements PlanningService {
item.getId(),
shopId,
artist.getId(),
product.getTitle(),
resolveAppointmentProductTitle(product, dto),
startTime,
endTime,
trimToNull(dto.getClientRequestId())
@@ -260,7 +267,9 @@ public class PlanningServiceImpl implements PlanningService {
LocalDateTime endTime = startTime.plusMinutes(durationMinutes);
ensureWithinBusinessHours(order.getShopId(), startTime, endTime);
BigDecimal unitPrice = product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
BigDecimal unitPrice = product == null
? resolveAppointmentUnitPrice(null, dto)
: product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
BigDecimal amount = unitPrice.multiply(BigDecimal.valueOf(quantity));
appointmentCapacityService.moveReservationForArtistChange(
@@ -269,7 +278,7 @@ public class PlanningServiceImpl implements PlanningService {
order.getShopId(),
item.getArtistId(),
artist.getId(),
product.getTitle(),
resolveAppointmentProductTitle(product, dto),
startTime,
endTime
);
@@ -282,11 +291,12 @@ public class PlanningServiceImpl implements PlanningService {
order.setPayAmount(amount);
orderMapper.updateById(order);
item.setProductId(product.getId());
item.setProductId(product == null ? null : product.getId());
item.setQuantity(quantity);
item.setPrice(unitPrice);
item.setArtistId(artist.getId());
item.setAppointmentTime(startTime);
applyAppointmentProductSnapshot(item, product, dto);
if (dto.getDepositPaid() != null) {
item.setDepositPaid(dto.getDepositPaid());
}
@@ -312,7 +322,7 @@ public class PlanningServiceImpl implements PlanningService {
}
OrderDO order = requireAccessibleOrder(currentUser, item.getOrderId());
requireEditableAppointment(order);
ProductDO product = requireActiveProduct(item.getProductId(), order.getShopId());
ProductDO product = item.getProductId() == null ? null : requireActiveProduct(item.getProductId(), order.getShopId());
Long targetArtistId = dto.getArtistId() == null ? item.getArtistId() : dto.getArtistId();
UserDO artist = requireActiveArtist(targetArtistId, order.getShopId());
int durationMinutes = resolveDurationMinutes(product, dto.getDurationMinutes()) *
@@ -332,7 +342,7 @@ public class PlanningServiceImpl implements PlanningService {
order.getShopId(),
item.getArtistId(),
artist.getId(),
product.getTitle(),
resolveAppointmentDisplayTitle(null, item, product),
startTime,
endTime
);
@@ -343,6 +353,23 @@ public class PlanningServiceImpl implements PlanningService {
return getAppointment(currentUser, item.getId());
}
@Override
@Transactional
public PlanningAppointmentVO updateAppointmentImages(UserDO currentUser, Long orderItemId, PlanningAppointmentImageDTO dto) {
if (orderItemId == null || dto == null) {
throw new RuntimeException("预约图片信息不能为空");
}
OrderItemDO item = orderItemMapper.selectByIdForUpdate(orderItemId);
if (item == null || Integer.valueOf(1).equals(item.getIsDelete())) {
throw new RuntimeException("预约不存在");
}
OrderDO order = requireAccessibleOrder(currentUser, item.getOrderId());
requireEditableAppointment(order);
item.setAppointmentProductImageFileIds(trimToNull(dto.getImageFileIds()));
orderItemMapper.updateById(item);
return getAppointment(currentUser, item.getId());
}
@Override
@Transactional
public Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto) {
@@ -670,9 +697,7 @@ public class PlanningServiceImpl implements PlanningService {
vo.setCustomerName(resolveAppointmentCustomerName(order, customer));
vo.setCustomerPhone(customer == null ? null : firstNonBlank(customer.getContactPhone(), customer.getPhone(), ""));
vo.setProductId(product == null ? item == null ? null : item.getProductId() : product.getId());
vo.setProductTitle(reservation != null && hasText(reservation.getProductTitle())
? reservation.getProductTitle()
: product == null ? "预约作品" : product.getTitle());
vo.setProductTitle(resolveAppointmentDisplayTitle(reservation, item, product));
vo.setArtistId(artistId);
vo.setArtistName(artist == null ? "未分配" : artist.getName());
vo.setArtistColor(artist == null ? ARTIST_COLORS.get(0) : artist.getColor());
@@ -693,6 +718,11 @@ public class PlanningServiceImpl implements PlanningService {
vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus));
vo.setAmount(order == null ? null : order.getActualAmount());
vo.setRemark(order == null ? null : order.getCustomerRemark());
vo.setProductDescription(resolveAppointmentProductDescription(item, product));
vo.setProductTags(resolveAppointmentProductTags(item, product));
vo.setProductPrecautions(resolveAppointmentProductPrecautions(item, product));
vo.setProductImageFileIds(resolveAppointmentProductImageFileIds(item, product));
vo.setProductImageUrls(resolveImageUrls(parseLongTokens(vo.getProductImageFileIds())));
return vo;
}
@@ -857,10 +887,11 @@ public class PlanningServiceImpl implements PlanningService {
if (dto.getProductId() != null) {
return requireActiveProduct(dto.getProductId(), shopId);
}
return createManualAppointmentProduct(dto, shopId);
requireManualAppointmentProduct(dto);
return null;
}
private ProductDO createManualAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
private void requireManualAppointmentProduct(PlanningAppointmentCreateDTO dto) {
String title = trimToNull(dto.getManualProductTitle());
if (!hasText(title)) {
throw new RuntimeException("请选择预约作品或填写手动作品名称");
@@ -869,30 +900,11 @@ public class PlanningServiceImpl implements PlanningService {
if (price == null || price.compareTo(BigDecimal.ZERO) < 0) {
throw new RuntimeException("手动作品价格不能小于0");
}
int durationMinutes = requireAppointmentDuration(dto.getDurationMinutes());
ProductDO product = new ProductDO();
product.setShopId(shopId);
product.setTitle(title);
product.setDescription(trimToNull(dto.getManualProductDescription()));
product.setTags(trimToNull(dto.getManualProductTags()));
product.setTargetAudience(trimToNull(dto.getManualProductTargetAudience()));
product.setPrecautions(trimToNull(dto.getManualProductPrecautions()));
product.setImageFileIds(trimToNull(dto.getManualProductImageFileIds()));
product.setPrice(price);
product.setLikeCount(0);
product.setCollectCount(0);
product.setApproximateDuration(durationMinutes + "分钟");
product.setBookableArtists(dto.getArtistId() == null ? null : String.valueOf(dto.getArtistId()));
product.setFrontVisible(0);
product.setSourceType(PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT);
product.setIsDelete(0);
productMapper.insert(product);
return product;
}
private BigDecimal resolveAppointmentUnitPrice(ProductDO product, PlanningAppointmentCreateDTO dto) {
if (dto.getManualProductPrice() == null) {
return product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
return product == null || product.getPrice() == null ? BigDecimal.ZERO : product.getPrice();
}
if (dto.getManualProductPrice().compareTo(BigDecimal.ZERO) < 0) {
throw new RuntimeException("本次价格不能小于0");
@@ -900,6 +912,30 @@ public class PlanningServiceImpl implements PlanningService {
return dto.getManualProductPrice();
}
private void applyAppointmentProductSnapshot(OrderItemDO item, ProductDO product, PlanningAppointmentCreateDTO dto) {
item.setAppointmentProductTitle(resolveAppointmentProductTitle(product, dto));
item.setAppointmentProductDescription(product == null
? trimToNull(dto.getManualProductDescription())
: trimToNull(product.getDescription()));
item.setAppointmentProductTags(product == null
? trimToNull(dto.getManualProductTags())
: trimToNull(product.getTags()));
item.setAppointmentProductPrecautions(product == null
? trimToNull(dto.getManualProductPrecautions())
: trimToNull(product.getPrecautions()));
item.setAppointmentProductImageFileIds(product == null
? trimToNull(dto.getManualProductImageFileIds())
: trimToNull(product.getImageFileIds()));
}
private String resolveAppointmentProductTitle(ProductDO product, PlanningAppointmentCreateDTO dto) {
return firstNonBlank(
dto == null ? null : dto.getManualProductTitle(),
product == null ? null : product.getTitle(),
"预约作品"
);
}
private int requireAppointmentDuration(Integer durationMinutes) {
if (durationMinutes == null || durationMinutes <= 0) {
throw new RuntimeException("预约时长不能为空且必须大于0分钟");
@@ -984,6 +1020,47 @@ public class PlanningServiceImpl implements PlanningService {
);
}
private String resolveAppointmentDisplayTitle(AppointmentReservationDO reservation, OrderItemDO item, ProductDO product) {
return firstNonBlank(
reservation == null ? null : reservation.getProductTitle(),
item == null ? null : item.getAppointmentProductTitle(),
product == null ? null : product.getTitle(),
"预约作品"
);
}
private String resolveAppointmentProductDescription(OrderItemDO item, ProductDO product) {
return firstNonBlank(
item == null ? null : item.getAppointmentProductDescription(),
product == null ? null : product.getDescription(),
""
);
}
private String resolveAppointmentProductTags(OrderItemDO item, ProductDO product) {
return firstNonBlank(
item == null ? null : item.getAppointmentProductTags(),
product == null ? null : product.getTags(),
""
);
}
private String resolveAppointmentProductPrecautions(OrderItemDO item, ProductDO product) {
return firstNonBlank(
item == null ? null : item.getAppointmentProductPrecautions(),
product == null ? null : product.getPrecautions(),
""
);
}
private String resolveAppointmentProductImageFileIds(OrderItemDO item, ProductDO product) {
return firstNonBlank(
item == null ? null : item.getAppointmentProductImageFileIds(),
product == null ? null : product.getImageFileIds(),
""
);
}
private OrderDO requireAccessibleOrder(UserDO currentUser, Long orderId) {
OrderDO order = orderMapper.selectById(orderId);
if (order == null || Integer.valueOf(1).equals(order.getIsDelete())) {
@@ -1176,6 +1253,45 @@ public class PlanningServiceImpl implements PlanningService {
return list == null ? List.of() : list;
}
private List<Long> parseLongTokens(String value) {
if (!hasText(value)) {
return List.of();
}
List<Long> result = new ArrayList<>();
String[] tokens = value.split(",");
for (int index = 0; index < tokens.length; index += 1) {
String token = tokens[index].trim();
if (token.isEmpty()) {
continue;
}
try {
result.add(Long.parseLong(token));
} catch (NumberFormatException e) {
throw new RuntimeException("预约作品图片文件ID格式不正确:" + token);
}
}
return result;
}
private List<String> resolveImageUrls(List<Long> fileIds) {
if (fileIds == null || fileIds.isEmpty()) {
return List.of();
}
Map<Long, ObjectStorageFileVO> fileMap = objectStorageFileService.getObjectStorageFileMapByIds(new LinkedHashSet<>(fileIds));
List<String> urls = new ArrayList<>();
for (Long fileId : fileIds) {
ObjectStorageFileVO file = fileMap.get(fileId);
if (file == null) {
continue;
}
String imageUrl = objectStorageUrlSupport.toAccessibleUrl(file);
if (hasText(imageUrl)) {
urls.add(imageUrl);
}
}
return urls;
}
private String firstNonBlank(String... values) {
for (String value : values) {
if (hasText(value)) {
@@ -3,6 +3,8 @@ package com.xiaowang.jayucloud.core.modules.planning.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Data
public class PlanningAppointmentVO {
@@ -33,4 +35,9 @@ public class PlanningAppointmentVO {
private String conflictReason;
private BigDecimal amount;
private String remark;
private String productDescription;
private String productTags;
private String productPrecautions;
private String productImageFileIds;
private List<String> productImageUrls = new ArrayList<>();
}
@@ -6,12 +6,16 @@ import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleException
import com.xiaowang.jayucloud.core.modules.artist.mapper.NailArtistInfoMapper;
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleDO;
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleRuleDO;
import com.xiaowang.jayucloud.core.modules.file.service.ObjectStorageFileService;
import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
import com.xiaowang.jayucloud.core.modules.order.entity.OrderItemDO;
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderItemMapper;
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderMapper;
import com.xiaowang.jayucloud.core.modules.order.service.OrderService;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentImageDTO;
import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO;
import com.xiaowang.jayucloud.core.modules.planning.entity.AppointmentReservationDO;
import com.xiaowang.jayucloud.core.modules.planning.mapper.AppointmentReservationMapper;
@@ -37,6 +41,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -76,6 +81,12 @@ class PlanningServiceImplTest {
@Mock
private ProductMapper productMapper;
@Mock
private ObjectStorageFileService objectStorageFileService;
@Mock
private ObjectStorageUrlSupport objectStorageUrlSupport;
@Mock
private ShopMapper shopMapper;
@@ -106,6 +117,8 @@ class PlanningServiceImplTest {
orderMapper,
orderItemMapper,
productMapper,
objectStorageFileService,
objectStorageUrlSupport,
shopMapper,
shopScheduleExceptionMapper,
appointmentCapacityService,
@@ -115,7 +128,7 @@ class PlanningServiceImplTest {
}
@Test
void createAppointmentShouldHideManualProductFromFront() {
void createAppointmentShouldStoreManualProductSnapshotWithoutCreatingProduct() {
UserDO manager = user(2, 8L);
UserDO artist = user(3, 8L);
artist.setId(20L);
@@ -132,14 +145,14 @@ class PlanningServiceImplTest {
dto.setDurationMinutes(90);
dto.setManualProductTitle(" 日落贝壳 ");
dto.setManualProductPrice(new BigDecimal("168.00"));
dto.setManualProductDescription(" 轻透贝壳款 ");
dto.setManualProductTags(" 贝壳 ");
dto.setManualProductPrecautions(" 避免磕碰 ");
dto.setManualProductImageFileIds("501,502");
dto.setClientRequestId("manual-product-test");
OrderItemDO[] storedItem = new OrderItemDO[1];
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
ProductDO product = invocation.getArgument(0);
product.setId(100L);
return 1;
});
when(userMapper.selectById(20L)).thenReturn(artist);
when(userMapper.selectById(30L)).thenReturn(customer);
when(shopMapper.selectById(8L)).thenReturn(shop);
@@ -152,19 +165,10 @@ class PlanningServiceImplTest {
when(orderItemMapper.insert(any(OrderItemDO.class))).thenAnswer(invocation -> {
OrderItemDO item = invocation.getArgument(0);
item.setId(300L);
storedItem[0] = item;
return 1;
});
when(orderItemMapper.selectById(300L)).thenAnswer(invocation -> {
OrderItemDO item = new OrderItemDO();
item.setId(300L);
item.setOrderId(200L);
item.setProductId(100L);
item.setArtistId(20L);
item.setQuantity(1);
item.setAppointmentTime(LocalDateTime.of(2026, 6, 26, 13, 0));
item.setIsDelete(0);
return item;
});
when(orderItemMapper.selectById(300L)).thenAnswer(invocation -> storedItem[0]);
when(orderMapper.selectById(200L)).thenAnswer(invocation -> {
OrderDO order = new OrderDO();
order.setId(200L);
@@ -175,18 +179,6 @@ class PlanningServiceImplTest {
order.setIsDelete(0);
return order;
});
when(productMapper.selectById(100L)).thenAnswer(invocation -> {
ProductDO product = new ProductDO();
product.setId(100L);
product.setShopId(8L);
product.setTitle("日落贝壳");
product.setPrice(new BigDecimal("168.00"));
product.setApproximateDuration("90分钟");
product.setFrontVisible(0);
product.setSourceType("MANAGER_APPOINTMENT");
product.setIsDelete(0);
return product;
});
AppointmentReservationDO reservation = new AppointmentReservationDO();
reservation.setOrderItemId(300L);
reservation.setArtistId(20L);
@@ -195,20 +187,33 @@ class PlanningServiceImplTest {
reservation.setAppointmentEndTime(LocalDateTime.of(2026, 6, 26, 14, 30));
when(appointmentReservationMapper.selectOne(any())).thenReturn(reservation);
when(userMapper.selectBatchIds(any())).thenReturn(List.of(customer));
ObjectStorageFileVO firstFile = new ObjectStorageFileVO();
firstFile.setId(501L);
ObjectStorageFileVO secondFile = new ObjectStorageFileVO();
secondFile.setId(502L);
when(objectStorageFileService.getObjectStorageFileMapByIds(any())).thenReturn(Map.of(
501L, firstFile,
502L, secondFile
));
when(objectStorageUrlSupport.toAccessibleUrl(firstFile)).thenReturn("https://img.example/501.jpg");
when(objectStorageUrlSupport.toAccessibleUrl(secondFile)).thenReturn("https://img.example/502.jpg");
var appointment = planningService.createAppointment(manager, dto);
ArgumentCaptor<ProductDO> captor = ArgumentCaptor.forClass(ProductDO.class);
org.mockito.Mockito.verify(productMapper).insert(captor.capture());
ProductDO product = captor.getValue();
assertThat(product.getTitle()).isEqualTo("日落贝壳");
assertThat(product.getFrontVisible()).isZero();
assertThat(product.getSourceType()).isEqualTo("MANAGER_APPOINTMENT");
assertThat(product.getImageFileIds()).isNull();
org.mockito.Mockito.verify(productMapper, org.mockito.Mockito.never()).insert(any(ProductDO.class));
assertThat(storedItem[0].getProductId()).isNull();
assertThat(storedItem[0].getAppointmentProductTitle()).isEqualTo("日落贝壳");
assertThat(storedItem[0].getAppointmentProductDescription()).isEqualTo("轻透贝壳款");
assertThat(storedItem[0].getAppointmentProductTags()).isEqualTo("贝壳");
assertThat(storedItem[0].getAppointmentProductPrecautions()).isEqualTo("避免磕碰");
assertThat(storedItem[0].getAppointmentProductImageFileIds()).isEqualTo("501,502");
ArgumentCaptor<OrderDO> orderCaptor = ArgumentCaptor.forClass(OrderDO.class);
org.mockito.Mockito.verify(orderMapper).insert(orderCaptor.capture());
assertThat(orderCaptor.getValue().getCustomerName()).isEqualTo("王女士");
assertThat(appointment.getCustomerName()).isEqualTo("王女士");
assertThat(appointment.getProductTitle()).isEqualTo("日落贝壳");
assertThat(appointment.getProductImageFileIds()).isEqualTo("501,502");
assertThat(appointment.getProductImageUrls()).containsExactly("https://img.example/501.jpg", "https://img.example/502.jpg");
}
@Test
@@ -230,17 +235,10 @@ class PlanningServiceImplTest {
dto.setNeedRemoval(true);
dto.setFromMeituan(true);
ProductDO[] storedProduct = new ProductDO[1];
UserDO[] storedCustomer = new UserDO[1];
OrderDO[] storedOrder = new OrderDO[1];
OrderItemDO[] storedItem = new OrderItemDO[1];
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
ProductDO product = invocation.getArgument(0);
product.setId(100L);
storedProduct[0] = product;
return 1;
});
when(userMapper.selectById(20L)).thenReturn(artist);
when(shopMapper.selectById(8L)).thenReturn(shop);
when(snowflakeIdGenerator.nextIdString()).thenReturn("202607200001", "202607200002");
@@ -264,10 +262,10 @@ class PlanningServiceImplTest {
});
when(orderItemMapper.selectById(300L)).thenAnswer(invocation -> storedItem[0]);
when(orderMapper.selectById(200L)).thenAnswer(invocation -> storedOrder[0]);
when(productMapper.selectById(100L)).thenAnswer(invocation -> storedProduct[0]);
AppointmentReservationDO reservation = reservation(20L, 200L, 300L,
LocalDateTime.of(2026, 7, 20, 15, 0),
LocalDateTime.of(2026, 7, 20, 16, 0));
reservation.setProductTitle("净色护理");
when(appointmentReservationMapper.selectOne(any())).thenReturn(reservation);
when(userMapper.selectBatchIds(any())).thenAnswer(invocation -> List.of(storedCustomer[0]));
@@ -279,10 +277,14 @@ class PlanningServiceImplTest {
assertThat(customerCaptor.getValue().getPhone()).isNull();
assertThat(customerCaptor.getValue().getContactPhone()).isNull();
assertThat(customerCaptor.getValue().getAccount()).isEqualTo("guest202607200001");
org.mockito.Mockito.verify(productMapper, org.mockito.Mockito.never()).insert(any(ProductDO.class));
assertThat(storedItem[0].getProductId()).isNull();
assertThat(storedItem[0].getAppointmentProductTitle()).isEqualTo("净色护理");
assertThat(storedItem[0].getDepositPaid()).isTrue();
assertThat(storedItem[0].getNeedRemoval()).isTrue();
assertThat(storedItem[0].getFromMeituan()).isTrue();
assertThat(appointment.getCustomerName()).isEqualTo("到店王女士");
assertThat(appointment.getProductTitle()).isEqualTo("净色护理");
assertThat(appointment.getDepositPaid()).isTrue();
assertThat(appointment.getNeedRemoval()).isTrue();
assertThat(appointment.getFromMeituan()).isTrue();
@@ -368,11 +370,6 @@ class PlanningServiceImplTest {
dto.setManualProductPrice(new BigDecimal("100.00"));
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
ProductDO product = invocation.getArgument(0);
product.setId(100L);
return 1;
});
when(userMapper.selectById(20L)).thenReturn(artist);
when(userMapper.selectById(30L)).thenReturn(customer);
when(shopMapper.selectById(8L)).thenReturn(shop);
@@ -404,6 +401,53 @@ class PlanningServiceImplTest {
org.mockito.Mockito.verify(orderItemMapper, org.mockito.Mockito.never()).updateById(any());
}
@Test
void updateAppointmentImagesShouldPersistSnapshotImageIdsAndReturnUrls() {
UserDO manager = user(2, 8L);
UserDO artist = user(3, 8L);
artist.setId(20L);
artist.setNickname("小王");
UserDO customer = user(0, 8L);
customer.setId(30L);
customer.setNickname("王女士");
OrderDO order = order(200L, 8L, 30L);
OrderItemDO item = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 21, 13, 0));
item.setAppointmentProductTitle("手绘款");
item.setAppointmentProductImageFileIds("501");
PlanningAppointmentImageDTO dto = new PlanningAppointmentImageDTO();
dto.setImageFileIds("601,602");
AppointmentReservationDO reservation = reservation(20L, 200L, 300L,
LocalDateTime.of(2026, 7, 21, 13, 0),
LocalDateTime.of(2026, 7, 21, 14, 0));
reservation.setProductTitle("手绘款");
ObjectStorageFileVO firstFile = new ObjectStorageFileVO();
firstFile.setId(601L);
ObjectStorageFileVO secondFile = new ObjectStorageFileVO();
secondFile.setId(602L);
when(orderItemMapper.selectByIdForUpdate(300L)).thenReturn(item);
when(orderMapper.selectById(200L)).thenReturn(order);
when(orderItemMapper.selectById(300L)).thenReturn(item);
when(appointmentReservationMapper.selectOne(any())).thenReturn(reservation);
when(userMapper.selectList(any())).thenReturn(List.of(artist));
when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of());
when(userMapper.selectBatchIds(any())).thenReturn(List.of(customer));
when(objectStorageFileService.getObjectStorageFileMapByIds(any())).thenReturn(Map.of(
601L, firstFile,
602L, secondFile
));
when(objectStorageUrlSupport.toAccessibleUrl(firstFile)).thenReturn("https://img.example/601.jpg");
when(objectStorageUrlSupport.toAccessibleUrl(secondFile)).thenReturn("https://img.example/602.jpg");
var appointment = planningService.updateAppointmentImages(manager, 300L, dto);
assertThat(item.getAppointmentProductImageFileIds()).isEqualTo("601,602");
org.mockito.Mockito.verify(orderItemMapper).updateById(item);
assertThat(appointment.getProductTitle()).isEqualTo("手绘款");
assertThat(appointment.getProductImageFileIds()).isEqualTo("601,602");
assertThat(appointment.getProductImageUrls()).containsExactly("https://img.example/601.jpg", "https://img.example/602.jpg");
}
@Test
void calendarMarksMonthAvailabilityByContinuousNinetyMinuteWindow() {
UserDO manager = user(2, 8L);
+8
View File
@@ -30,6 +30,14 @@ module.exports = {
})
},
updateAppointmentImages(orderItemId, data) {
return request({
url: `/manager/planning/appointments/${orderItemId}/images`,
method: 'PUT',
data
})
},
updateStatus(orderId, status) {
return request({
url: `/manager/planning/appointments/${orderId}/status`,
+9
View File
@@ -0,0 +1,9 @@
const request = require('../utils/request')
module.exports = {
listAll() {
return request({
url: '/tag/list/all'
})
}
}
@@ -1,5 +1,44 @@
const planningApi = require('../../api/planning')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { chooseImageFilePaths, uploadObjectFile } = require('../../utils/upload')
function canTransferAppointment() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
return Number(userInfo.type) === 2
}
function splitImageValues(value) {
return String(value || '')
.split(',')
.map(item => item.trim())
.filter(Boolean)
}
function resolveProductImageUrls(appointment) {
if (appointment && Array.isArray(appointment.productImageUrls)) {
return appointment.productImageUrls.filter(Boolean)
}
return []
}
async function uploadAppointmentImageFiles(limit) {
const filePaths = await chooseImageFilePaths(limit)
const fileIds = []
const imageUrls = []
for (let index = 0; index < filePaths.length; index += 1) {
const filePath = filePaths[index]
const uploadResult = await uploadObjectFile(filePath)
const fileId = uploadResult.id || uploadResult.fileId
const fileUrl = uploadResult.fileUrl || uploadResult.primaryUrl || filePath
if (!fileId) {
throw new Error('预约图片上传成功但未返回文件ID')
}
fileIds.push(String(fileId))
imageUrls.push(fileUrl)
}
return { fileIds, imageUrls }
}
Page({
data: {
@@ -7,11 +46,18 @@ Page({
appointment: {},
avatarText: '',
timeText: '',
productImageUrls: [],
productImageFileIds: '',
imageUploading: false,
canTransferAppointment: false,
loadError: ''
},
onLoad(options) {
this.setData({ id: options.id || '' })
this.setData({
id: options.id || '',
canTransferAppointment: canTransferAppointment()
})
this.loadDetail()
},
@@ -24,16 +70,22 @@ Page({
appointment: {},
avatarText: '',
timeText: '',
productImageUrls: [],
productImageFileIds: '',
loadError: error.message || '预约详情加载失败'
})
}
},
applyAppointment(appointment) {
const imageUrls = resolveProductImageUrls(appointment)
this.setData({
appointment,
avatarText: String(appointment.customerName || '客').slice(0, 1),
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
productImageUrls: imageUrls,
productImageFileIds: String(appointment.productImageFileIds || ''),
canTransferAppointment: canTransferAppointment(),
loadError: ''
})
},
@@ -62,9 +114,97 @@ Page({
},
goTransfer() {
if (!this.data.canTransferAppointment) {
wx.showToast({ title: '只有店长可以改派预约', icon: 'none' })
return
}
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
},
async persistAppointmentImages(fileIds) {
const appointment = await planningApi.updateAppointmentImages(this.data.id, {
imageFileIds: fileIds.join(',')
})
markPlanningRefresh()
this.applyAppointment(appointment)
},
async chooseAppointmentImages() {
if (this.data.imageUploading) {
return
}
const currentFileIds = splitImageValues(this.data.productImageFileIds)
const remainingCount = 9 - currentFileIds.length
if (remainingCount <= 0) {
wx.showToast({ title: '最多上传 9 张作品图片', icon: 'none' })
return
}
this.setData({ imageUploading: true })
try {
const uploaded = await uploadAppointmentImageFiles(remainingCount)
if (uploaded.fileIds.length === 0) {
return
}
await this.persistAppointmentImages(currentFileIds.concat(uploaded.fileIds))
wx.showToast({ title: '图片已保存' })
} catch (error) {
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
} finally {
this.setData({ imageUploading: false })
}
},
async replaceAppointmentImages() {
if (this.data.imageUploading) {
return
}
this.setData({ imageUploading: true })
try {
const uploaded = await uploadAppointmentImageFiles(9)
if (uploaded.fileIds.length === 0) {
return
}
await this.persistAppointmentImages(uploaded.fileIds)
wx.showToast({ title: '图片已保存' })
} catch (error) {
wx.showToast({ title: error.message || '图片上传失败', icon: 'none' })
} finally {
this.setData({ imageUploading: false })
}
},
async removeAppointmentImage(event) {
if (this.data.imageUploading) {
return
}
const index = Number(event.currentTarget.dataset.index)
const currentFileIds = splitImageValues(this.data.productImageFileIds)
if (!Number.isInteger(index) || index < 0 || index >= currentFileIds.length) {
return
}
const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index)
this.setData({ imageUploading: true })
try {
await this.persistAppointmentImages(nextFileIds)
wx.showToast({ title: '图片已保存' })
} catch (error) {
wx.showToast({ title: error.message || '图片保存失败', icon: 'none' })
} finally {
this.setData({ imageUploading: false })
}
},
previewProductImage(event) {
const current = this.data.productImageUrls[Number(event.currentTarget.dataset.index)]
if (!current) {
return
}
wx.previewImage({
current,
urls: this.data.productImageUrls
})
},
back() {
wx.navigateBack()
}
@@ -15,7 +15,7 @@
</view>
<view class="detail-actions">
<text class="tag">{{appointment.statusText}}</text>
<button class="small-action" bindtap="goTransfer">改派</button>
<button wx:if="{{canTransferAppointment && appointment.canEdit}}" class="small-action" bindtap="goTransfer">改派</button>
</view>
</view>
<view class="detail-grid">
@@ -38,6 +38,25 @@
</view>
</view>
<view wx:if="{{!loadError}}" class="section">
<view class="section-head">
<view class="section-title">作品图片</view>
<button class="text-btn image-action" loading="{{imageUploading}}" disabled="{{imageUploading}}" bindtap="replaceAppointmentImages">{{productImageUrls.length ? '重新上传' : '上传图片'}}</button>
</view>
<view class="card image-card">
<view wx:if="{{productImageUrls.length}}" class="detail-image-list">
<view wx:for="{{productImageUrls}}" wx:key="*this" class="detail-image-item">
<image class="detail-image" src="{{item}}" mode="aspectFill" data-index="{{index}}" bindtap="previewProductImage"></image>
<view class="detail-image-remove" data-index="{{index}}" catchtap="removeAppointmentImage">×</view>
</view>
<view wx:if="{{productImageUrls.length < 9}}" class="detail-image-add {{imageUploading ? 'disabled' : ''}}" bindtap="chooseAppointmentImages">
<text>{{imageUploading ? '...' : '+'}}</text>
</view>
</view>
<view wx:else class="detail-image-empty">暂无图片</view>
</view>
</view>
<view wx:if="{{!loadError}}" class="section">
<view class="section-title">备注</view>
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
@@ -95,6 +95,93 @@
line-height: 1.6;
}
.section-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.image-action {
flex: 0 0 auto;
width: 156rpx;
min-width: 156rpx;
max-width: 156rpx;
padding: 0;
text-align: right;
}
.image-card {
padding: 20rpx;
}
.detail-image-list {
display: flex;
flex-wrap: wrap;
gap: 14rpx;
}
.detail-image-item {
position: relative;
width: 150rpx;
height: 150rpx;
}
.detail-image {
display: block;
width: 150rpx;
height: 150rpx;
border-radius: 16rpx;
background: #efe5da;
}
.detail-image-remove {
position: absolute;
top: -10rpx;
right: -10rpx;
display: flex;
align-items: center;
justify-content: center;
width: 34rpx;
height: 34rpx;
border-radius: 50%;
background: #bf4949;
color: #fff;
font-size: 24rpx;
font-weight: 900;
line-height: 34rpx;
}
.detail-image-add {
display: flex;
align-items: center;
justify-content: center;
width: 150rpx;
height: 150rpx;
border: 2rpx dashed #d5bfa9;
border-radius: 16rpx;
background: #fff8ef;
color: #b78b63;
font-size: 52rpx;
font-weight: 500;
line-height: 1;
}
.detail-image-add.disabled {
opacity: 0.55;
}
.detail-image-empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 142rpx;
border-radius: 16rpx;
background: #f7efe7;
color: #9a9288;
font-size: 26rpx;
}
.action-row {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
+115 -17
View File
@@ -1,5 +1,6 @@
const planningApi = require('../../api/planning')
const productsApi = require('../../api/products')
const tagsApi = require('../../api/tags')
const customersApi = require('../../api/customers')
const dateUtil = require('../../utils/date')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
@@ -256,6 +257,58 @@ function normalizeProduct(product, artists) {
}
}
function normalizeTagOption(tag) {
const name = String((tag && (tag.displayName || tag.tagName || tag.name)) || '').trim()
if (!name) {
return null
}
return {
id: (tag && tag.id) || name,
name
}
}
function normalizeTagOptions(tags) {
const source = Array.isArray(tags) ? tags : []
const names = new Set()
return source
.map(normalizeTagOption)
.filter(Boolean)
.filter(item => {
if (names.has(item.name)) {
return false
}
names.add(item.name)
return true
})
}
function resolveTagPickerIndex(tagOptions, value) {
const firstTag = String(value || '').split(/[;,,、]/)[0].trim()
if (!firstTag) {
return 0
}
const index = tagOptions.findIndex(item => item.name === firstTag)
return index >= 0 ? index : 0
}
function resolveTagValue(tagOptions, value) {
const tokens = String(value || '')
.split(/[;,,、]/)
.map(item => item.trim())
.filter(Boolean)
if (tokens.length === 0) {
return ''
}
if (!Array.isArray(tagOptions) || tagOptions.length === 0) {
return ''
}
const matched = tokens
.map(token => tagOptions.find(item => item.name === token))
.find(Boolean)
return matched ? matched.name : ''
}
function splitManualImageValues(value) {
return String(value || '')
.split(',')
@@ -335,6 +388,9 @@ Page({
manualProductImageUrls: [],
productKeyword: '',
productError: '',
tagOptions: [],
tagPickerIndex: 0,
tagError: '',
conflictTip: '',
conflictLevel: 'free',
canCreateAppointment: true,
@@ -385,12 +441,33 @@ Page({
productError: error.message || '作品列表加载失败'
})
}
await this.loadTags()
await this.loadArtists()
this.refreshProductCards()
await this.refreshAvailableTimes()
this.checkAvailability()
},
async loadTags() {
try {
const tagsData = await tagsApi.listAll()
const tagOptions = normalizeTagOptions(tagsData.list || tagsData || [])
const selectedTag = resolveTagValue(tagOptions, this.data.form.manualProductTags)
this.setData({
tagOptions,
tagPickerIndex: resolveTagPickerIndex(tagOptions, selectedTag),
'form.manualProductTags': selectedTag,
tagError: ''
})
} catch (error) {
this.setData({
tagOptions: [],
tagPickerIndex: 0,
tagError: error.message || '标签加载失败'
})
}
},
async loadArtists() {
try {
const calendar = await planningApi.calendar({
@@ -522,17 +599,20 @@ Page({
},
openProductModal() {
this.openManualProductPanel()
},
openProductTemplateSheet() {
this.setData({ productKeyword: '' })
this.refreshProductCards()
this.setData({
productModalVisible: true,
manualProductPanelVisible: false
productModalVisible: true
})
},
closeProductModal() {
this.setData({
productModalVisible: false,
manualProductPanelVisible: false
productModalVisible: false
})
},
@@ -542,7 +622,9 @@ Page({
: splitManualImageValues(this.data.form.manualProductImageUrl)
this.setData({
manualProductPanelVisible: true,
manualProductImageUrls: imageUrls
productModalVisible: false,
manualProductImageUrls: imageUrls,
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, this.data.form.manualProductTags)
})
},
@@ -550,7 +632,10 @@ Page({
if (this.data.manualImageUploading) {
return
}
this.setData({ manualProductPanelVisible: false })
this.setData({
manualProductPanelVisible: false,
productModalVisible: false
})
},
stopTap() {
@@ -564,30 +649,43 @@ Page({
selectProduct(event) {
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {}
const price = formatProductPrice(selectedProduct.price)
const productTag = resolveTagValue(this.data.tagOptions, parseProductTags(selectedProduct).join(','))
const imageUrls = Array.isArray(selectedProduct.imageUrls) ? selectedProduct.imageUrls : []
this.setData({
selectedProduct,
'form.productId': selectedProduct.id,
'form.manualProductTitle': '',
'form.productId': '',
'form.manualProductTitle': selectedProduct.title || '',
'form.manualProductPrice': price,
'form.manualProductDescription': '',
'form.manualProductTags': '',
'form.manualProductPrecautions': '',
'form.manualProductImageFileIds': '',
'form.manualProductImageUrl': '',
manualProductImageUrls: [],
manualProductPanelVisible: false,
'form.manualProductDescription': selectedProduct.description || '',
'form.manualProductTags': productTag,
'form.manualProductPrecautions': selectedProduct.precautions || '',
'form.manualProductImageFileIds': selectedProduct.imageFileIds || '',
'form.manualProductImageUrl': imageUrls.join(','),
manualProductImageUrls: imageUrls,
productModalVisible: false,
tagPickerIndex: resolveTagPickerIndex(this.data.tagOptions, productTag),
'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || '')
})
this.closeProductModal()
this.refreshAvailableTimes()
this.checkAvailability()
},
onManualTagChange(event) {
const tag = this.data.tagOptions[Number(event.detail.value)]
if (!tag) {
return
}
this.setData({
tagPickerIndex: Number(event.detail.value),
'form.manualProductTags': tag.name
})
},
useManualProduct() {
const title = String(this.data.form.manualProductTitle || '').trim()
const price = Number(this.data.form.manualProductPrice)
if (!title || Number.isNaN(price) || price < 0) {
wx.showToast({ title: '请填写手动预约作品名称和价格', icon: 'none' })
wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
return
}
this.setData({
@@ -31,10 +31,9 @@
</picker>
</view>
<view class="field">
<text class="field-label required">预约作品</text>
<text class="field-label required">选择作品</text>
<view class="field-value product-value" bindtap="openProductModal">
<text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text>
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
<text>{{form.manualProductTitle || selectedProduct.title || '请选择作品'}}</text>
</view>
</view>
<view wx:if="{{form.productId || form.manualProductTitle}}" class="field">
@@ -98,18 +97,58 @@
<text class="tip-text">{{conflictTip}}</text>
</view>
<view wx:if="{{productModalVisible}}" class="modal-mask" bindtap="closeProductModal">
<view class="product-modal" catchtap="stopTap">
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
<view class="manual-sheet" catchtap="stopTap">
<view class="manual-sheet-head">
<text class="manual-sheet-title">选择作品</text>
<view class="modal-close" bindtap="closeManualProductPanel">×</view>
</view>
<button class="secondary-btn template-entry-btn" bindtap="openProductTemplateSheet">使用已有作品模板</button>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<input class="manual-input-full" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
<view class="manual-grid single">
<picker range="{{tagOptions}}" range-key="name" value="{{tagPickerIndex}}" bindchange="onManualTagChange" disabled="{{tagOptions.length === 0}}">
<view class="manual-picker {{form.manualProductTags ? '' : 'placeholder'}}">
<text>{{form.manualProductTags || (tagOptions.length ? '请选择标签' : '暂无标签')}}</text>
<text class="manual-picker-arrow">›</text>
</view>
</picker>
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
</view>
<view wx:if="{{tagError}}" class="manual-tag-error">{{tagError}}</view>
<view class="manual-image-section">
<view class="manual-image-head">
<text class="manual-image-title">作品图片</text>
</view>
<view class="manual-image-list">
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
<image class="manual-image" src="{{imageUrl}}" mode="aspectFill"></image>
<view class="manual-image-remove" data-index="{{index}}" catchtap="removeManualProductImage">×</view>
</view>
<view class="manual-image-add {{manualImageUploading ? 'disabled' : ''}}" bindtap="chooseManualProductImage">
<text>{{manualImageUploading ? '...' : '+'}}</text>
</view>
</view>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">保存内容</button>
</view>
</view>
<view wx:if="{{productModalVisible}}" class="modal-mask template-mask" catchtap="stopTap">
<view class="product-modal template-modal" catchtap="stopTap">
<view class="modal-head">
<view>
<text class="modal-title">选择预约作品</text>
<text class="modal-title">使用已有作品模板</text>
</view>
<view class="modal-close" bindtap="closeProductModal">×</view>
</view>
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
<scroll-view class="product-list" scroll-y>
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option" data-id="{{item.id}}" bindtap="selectProduct">
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
<view wx:else class="product-cover placeholder">图</view>
<view class="product-info">
@@ -125,49 +164,6 @@
</view>
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
</scroll-view>
<view class="manual-entry-card">
<view>
<text class="manual-entry-title">没有合适作品?</text>
<text class="manual-entry-desc">临时新增一个预约作品,提交时会一并保存到预约信息。</text>
</view>
<button class="secondary-btn manual-entry-btn" bindtap="openManualProductPanel">新增作品</button>
</view>
</view>
<view wx:if="{{manualProductPanelVisible}}" class="manual-mask" catchtap="stopTap">
<view class="manual-sheet" catchtap="stopTap">
<view class="manual-sheet-head">
<view>
<text class="manual-sheet-title">新增预约作品</text>
<text class="manual-sheet-subtitle">填写本次预约使用的作品信息</text>
</view>
<view class="modal-close" bindtap="closeManualProductPanel">×</view>
</view>
<text class="manual-title required-label">手动新增预约作品</text>
<view class="manual-grid">
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
</view>
<textarea class="manual-textarea" value="{{form.manualProductDescription}}" data-field="manualProductDescription" bindinput="onInput" placeholder="作品描述(选填)" />
<view class="manual-grid single">
<input value="{{form.manualProductTags}}" data-field="manualProductTags" bindinput="onInput" placeholder="标签,多个用逗号分隔(选填)" />
<input value="{{form.manualProductPrecautions}}" data-field="manualProductPrecautions" bindinput="onInput" placeholder="注意事项(选填)" />
</view>
<view class="manual-image-section">
<view class="manual-image-head">
<text class="manual-image-title">作品图片</text>
<text class="manual-image-desc">支持上传多张图片</text>
</view>
<view class="manual-image-list">
<view wx:for="{{manualProductImageUrls}}" wx:for-item="imageUrl" wx:key="*this" class="manual-image-item">
<image class="manual-image" src="{{imageUrl}}" mode="aspectFill"></image>
<view class="manual-image-remove" data-index="{{index}}" catchtap="removeManualProductImage">×</view>
</view>
<view wx:if="{{manualProductImageUrls.length === 0}}" class="manual-image-empty">图</view>
</view>
<button class="secondary-btn image-btn" loading="{{manualImageUploading}}" disabled="{{manualImageUploading}}" bindtap="chooseManualProductImage">上传图片</button>
</view>
<button class="secondary-btn manual-btn" bindtap="useManualProduct">确认新增</button>
</view>
</view>
</view>
@@ -277,6 +277,14 @@
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
}
.template-mask {
z-index: 100;
}
.template-modal {
max-height: 76vh;
}
.time-modal {
width: 100%;
max-height: 82vh;
@@ -583,6 +591,13 @@
max-width: 196rpx;
}
.template-entry-btn {
width: 100%;
min-width: 0;
max-width: 100%;
margin-bottom: 18rpx;
}
.manual-mask {
position: fixed;
inset: 0;
@@ -652,17 +667,54 @@
font-size: 26rpx;
}
.manual-textarea {
.manual-input-full {
width: 100%;
min-height: 120rpx;
height: 70rpx;
margin-top: 14rpx;
padding: 18rpx;
padding: 0 18rpx;
border-radius: 14rpx;
background: #fffaf4;
color: #302923;
font-size: 26rpx;
}
.manual-picker {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12rpx;
height: 70rpx;
padding: 0 18rpx;
border-radius: 14rpx;
background: #fffaf4;
color: #302923;
font-size: 26rpx;
}
.manual-picker.placeholder {
color: #aaa096;
}
.manual-picker text:first-child {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.manual-picker-arrow {
flex: 0 0 auto;
color: #b78b63;
font-size: 34rpx;
line-height: 1;
}
.manual-tag-error {
margin-top: 10rpx;
color: #b86858;
font-size: 22rpx;
}
.manual-image-row {
display: none;
}
@@ -726,6 +778,25 @@
font-weight: 900;
}
.manual-image-add {
display: flex;
align-items: center;
justify-content: center;
width: 104rpx;
height: 104rpx;
border: 2rpx dashed #d5bfa9;
border-radius: 16rpx;
background: #fff8ef;
color: #b78b63;
font-size: 46rpx;
font-weight: 500;
line-height: 1;
}
.manual-image-add.disabled {
opacity: 0.55;
}
.manual-image-remove {
position: absolute;
top: -10rpx;
+8
View File
@@ -243,3 +243,11 @@
- 执行方式:通过生产 Nacos API 删除旧 `JayuCloud` namespace,并清理旧 tenant 下残留的 `core.yaml`、`gateway.yaml`、`infra.yaml`、`secret.yaml`、`logging.yaml`;`datasource.yaml` 在旧 tenant 下原本不存在。全程只输出 dataId、HTTP 状态和脱敏摘要,不输出原始 YAML 或密钥。
- 对象存储复核:生产 `jayu-cloud / DEFAULT_GROUP` 中 `infra.yaml` 的 `minio.bucket-name`、`aliyun.oss.bucket-name` 均为 `jayucloud`,`secret.yaml` 的 `qiniu.kodo.bucket-name` 为 `jayucloud`;三台 Nacos 节点读取结果一致,配置已是期望值,本次未重复发布。
- 验证方式:`192.168.5.101`、`192.168.5.102`、`192.168.10.145` 下旧 `JayuCloud` / `jayuCloud` 的 6 个 dataId 均返回 `404`;当前生产 `jayu-cloud` 的 `core.yaml`、`gateway.yaml`、`datasource.yaml`、`infra.yaml`、`secret.yaml`、`logging.yaml` 均返回 `200`。
## 2026-07-21 店务小程序预约作品快照与图片维护
- 变更原因:店务小程序新增预约时,手动新增作品不应自动沉淀到作品库;选择作品入口需要直接进入本次预约作品内容弹窗,并支持使用现有作品模板回填;预约详情需要展示并维护新增预约作品图片;改派操作要求仅店长可用。
- 处理方式:后端将本次预约作品名称、描述、标签、注意事项和图片文件 ID 保存为 `t_order_item` 快照字段,新增预约图片更新接口,预约详情返回图片可访问 URL;店务小程序预约表单改为“选择作品”弹窗,现有作品列表移动到“使用已有作品模板”下方抽屉,标签改为当前店铺标签下拉值,图片上传改为图片列表后的加号入口;预约详情新增作品图片展示、上传、重传和删除,并仅店长显示改派入口。
- 数据库变更:新增 `scripts/sql/migrations/预约作品快照/预约作品快照字段_20260721.sql`,为 `t_order_item` 增加预约作品快照相关幂等列,并将 `product_id` 调整为可空以支持仅保存预约作品快照;不修改初始化 SQL。
- 影响范围:影响 `JY-Core` 预约创建、预约修改、预约详情、预约图片维护和改派权限;影响 `JY-Salon-WeChat` 预约表单、预约详情及标签/规划接口封装。
- 验证方式:`PlanningServiceImplTest` 通过 12 个用例;`JayuCloudSqlSchemaTest` 通过;小程序变更 JS 执行 Node 24 `--check` 通过;`git diff --check` 通过;GitNexus `detect_changes -r JayuCloud --scope unstaged` 结果为 low,影响流程 0。
+8
View File
@@ -192,3 +192,11 @@
- 处理方式:候选列表按当前分钟过滤今天的过去时段,`checkAvailability` 提交前再次拦截小于等于当前分钟的今天时间。
- 以后避免:所有“只能选择未来时间”的预约/排班入口,都要同时做候选过滤和提交前校验。
- 验证方式:用今天日期构造早于当前时间的预约时间,`checkAvailability` 应返回失败并提示选择当前时间之后的预约时间;JS 语法检查和 GitNexus 变更检测通过。
## 2026-07-21 Mockito 匹配 Lombok Data 空对象会互相相等
- 问题:`PlanningServiceImplTest` 给两个 `ObjectStorageFileVO` 分别 stub `toAccessibleUrl` 时,返回值都命中了第二个 URL,导致图片 URL 顺序断言失败。
- 原因:`ObjectStorageFileVO` 使用 Lombok `@Data`,两个字段全为空的新对象 `equals` 结果为 true;Mockito 参数匹配时第二个 stub 覆盖了第一个。
- 处理方式:测试对象设置不同的 `id` 后再作为 Map 值和 mock 参数使用,确保 equals 匹配可区分。
- 以后避免:对 Lombok `@Data` 值对象做 Mockito 精确参数 stub 时,不要使用字段全空的多个实例;设置主键/唯一字段,或改用 `thenAnswer` 按字段分派。
- 验证方式:`mvn -f JY-Core/pom.xml -Dtest=PlanningServiceImplTest test` 通过。
+10 -7
View File
@@ -2,18 +2,21 @@
## 当前任务
限制店务小程序预约表单只能选择未来预约时间。
改造店务小程序预约作品选择、预约作品图片展示/修改,并限制改派仅店长可用。
## 已完成
- 已在预约时间候选生成时过滤今天当前时间之前的时间段。
- 已在预约提交前的时段校验中拦截今天当前时间之前或等于当前时间的选择。
- 已在今天无未来可约时间时展示更明确的提示。
- 已通过小程序 JS 语法检查、`git diff --check` 和 GitNexus `detect-changes`。
- 后端预约创建不再为手动作品新增隐藏作品库记录,改为保存订单项预约作品快照。
- 后端预约详情返回预约作品描述、标签、注意事项、图片文件 ID 和图片 URL。
- 后端新增预约图片更新接口,并将店务/规划改派入口限制为店长。
- 店务小程序预约表单改为“选择作品”弹窗,模板列表移入“使用已有作品模板”抽屉,标签改为店铺标签下拉,图片上传改为加号入口。
- 店务小程序预约详情新增作品图片展示、上传、重传、删除和预览。
- 已更新服务层测试和项目变更记录。
- 已通过 `PlanningServiceImplTest`、`JayuCloudSqlSchemaTest`、小程序 JS 语法检查、`git diff --check` 和 GitNexus `detect_changes`。
## 下一步
- 无。
- 最终复查 diff,暂存本次任务相关文件并创建中文提交。
## 当前阻塞点
@@ -21,4 +24,4 @@
## 最近一次重要操作结果
2026-07-21 已完成实现与验证,GitNexus `detect-changes -r JayuCloud --scope unstaged` 结果为 low,影响流程 0。
2026-07-21 验证通过,GitNexus `detect_changes -r JayuCloud --scope unstaged` 结果为 low,影响流程 0。
@@ -0,0 +1,55 @@
CREATE DATABASE IF NOT EXISTS jayu_cloud DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use jayu_cloud;
DROP PROCEDURE IF EXISTS sp_jy_add_column_if_not_exists;
DELIMITER $$
CREATE PROCEDURE sp_jy_add_column_if_not_exists(
IN p_table_name varchar(128),
IN p_column_name varchar(128),
IN p_column_sql varchar(1000)
)
BEGIN
IF NOT EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = p_table_name
AND column_name = p_column_name
) THEN
SET @jy_sql = CONCAT('ALTER TABLE ', p_table_name, ' ADD COLUMN ', p_column_sql);
PREPARE jy_stmt FROM @jy_sql;
EXECUTE jy_stmt;
DEALLOCATE PREPARE jy_stmt;
END IF;
END$$
DELIMITER ;
CALL sp_jy_add_column_if_not_exists('t_order_item', 'appointment_product_title', '`appointment_product_title` varchar(200) NULL COMMENT ''预约作品名称快照'' AFTER `from_meituan`');
CALL sp_jy_add_column_if_not_exists('t_order_item', 'appointment_product_description', '`appointment_product_description` varchar(1000) NULL COMMENT ''预约作品描述快照'' AFTER `appointment_product_title`');
CALL sp_jy_add_column_if_not_exists('t_order_item', 'appointment_product_tags', '`appointment_product_tags` varchar(500) NULL COMMENT ''预约作品标签快照'' AFTER `appointment_product_description`');
CALL sp_jy_add_column_if_not_exists('t_order_item', 'appointment_product_precautions', '`appointment_product_precautions` varchar(1000) NULL COMMENT ''预约作品注意事项快照'' AFTER `appointment_product_tags`');
CALL sp_jy_add_column_if_not_exists('t_order_item', 'appointment_product_image_file_ids', '`appointment_product_image_file_ids` text NULL COMMENT ''预约作品图片文件ID快照'' AFTER `appointment_product_precautions`');
DROP PROCEDURE IF EXISTS sp_jy_add_column_if_not_exists;
DROP PROCEDURE IF EXISTS sp_jy_modify_order_item_product_id_nullable;
DELIMITER $$
CREATE PROCEDURE sp_jy_modify_order_item_product_id_nullable()
BEGIN
IF EXISTS (
SELECT 1
FROM information_schema.columns
WHERE table_schema = DATABASE()
AND table_name = 't_order_item'
AND column_name = 'product_id'
AND is_nullable = 'NO'
) THEN
ALTER TABLE t_order_item
MODIFY COLUMN `product_id` bigint unsigned NULL COMMENT '商品ID,预约作品快照可为空' AFTER `order_id`;
END IF;
END$$
DELIMITER ;
CALL sp_jy_modify_order_item_product_id_nullable();
DROP PROCEDURE IF EXISTS sp_jy_modify_order_item_product_id_nullable;