diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java index c96a7c36..c0bcbb6a 100644 --- a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/manager/controller/admin/AdminManagerController.java @@ -19,6 +19,7 @@ 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.PlanningAppointmentPriceDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO; import com.xiaowang.jayucloud.core.modules.planning.service.PlanningService; @@ -137,6 +138,16 @@ public class AdminManagerController { return Result.success(planningService.updateStatus(currentUser, orderId, dto)); } + @PutMapping("/planning/appointments/{orderItemId}/price") + @RequirePermission("order:process") + @OperationGuard(action = "manager-planning-update-appointment-price", ttlSeconds = 10, message = "预约价格处理中,请勿重复提交") + public Result updatePrice(HttpServletRequest request, + @PathVariable Long orderItemId, + @RequestBody PlanningAppointmentPriceDTO dto) { + UserDO currentUser = adminScopeHelper.getCurrentUser(request); + return Result.success(planningService.updateAppointmentPrice(currentUser, orderItemId, dto)); + } + @GetMapping("/customers") @RequirePermission("user:view") public Result> customers(HttpServletRequest request, diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/controller/admin/AdminPlanningController.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/controller/admin/AdminPlanningController.java index cfc43339..cca36841 100644 --- a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/controller/admin/AdminPlanningController.java +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/controller/admin/AdminPlanningController.java @@ -5,6 +5,7 @@ import com.xiaowang.jayucloud.core.annotation.RequirePermission; import com.xiaowang.jayucloud.core.common.Result; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentCreateDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentMoveDTO; +import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentPriceDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO; import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentUpdateDTO; import com.xiaowang.jayucloud.core.modules.user.entity.UserDO; @@ -93,6 +94,16 @@ public class AdminPlanningController { return Result.success(planningService.updateStatus(currentUser, orderId, dto)); } + @PutMapping("/appointments/{orderItemId}/price") + @RequirePermission("order:process") + @OperationGuard(action = "admin-planning-update-appointment-price", ttlSeconds = 10, message = "预约价格处理中,请勿重复提交") + public Result updatePrice(HttpServletRequest request, + @PathVariable Long orderItemId, + @RequestBody PlanningAppointmentPriceDTO dto) { + UserDO currentUser = adminScopeHelper.getCurrentUser(request); + return Result.success(planningService.updateAppointmentPrice(currentUser, orderItemId, dto)); + } + private void requireManagerOperator(UserDO currentUser) { if (Integer.valueOf(2).equals(currentUser.getType())) { return; diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/dto/PlanningAppointmentPriceDTO.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/dto/PlanningAppointmentPriceDTO.java new file mode 100644 index 00000000..da89f356 --- /dev/null +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/dto/PlanningAppointmentPriceDTO.java @@ -0,0 +1,10 @@ +package com.xiaowang.jayucloud.core.modules.planning.dto; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class PlanningAppointmentPriceDTO { + private BigDecimal price; +} diff --git a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/mapper/AppointmentReservationMapper.java b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/mapper/AppointmentReservationMapper.java index 16d954a1..fdb335ba 100644 --- a/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/mapper/AppointmentReservationMapper.java +++ b/JY-Core/src/main/java/com/xiaowang/jayucloud/core/modules/planning/mapper/AppointmentReservationMapper.java @@ -61,6 +61,9 @@ public interface AppointmentReservationMapper extends BaseMapper() + .eq(OrderItemDO::getId, item.getId()) + .eq(OrderItemDO::getOrderId, order.getId()) + .eq(OrderItemDO::getIsDelete, 0)); + if (itemUpdated == 0) { + throw new RuntimeException("预约项目已变化,请刷新后重试"); + } + + BigDecimal amount = calculateOrderAmount(order.getId()); + OrderDO orderUpdate = new OrderDO(); + orderUpdate.setTotalAmount(amount); + orderUpdate.setActualAmount(amount); + orderUpdate.setPayAmount(amount); + int orderUpdated = orderMapper.update(orderUpdate, new LambdaUpdateWrapper() + .eq(OrderDO::getId, order.getId()) + .eq(OrderDO::getStatus, order.getStatus()) + .eq(OrderDO::getIsDelete, 0)); + if (orderUpdated == 0) { + throw new RuntimeException("订单状态已变化,请刷新后重试"); + } + + item.setPrice(price); + order.setTotalAmount(amount); + order.setActualAmount(amount); + order.setPayAmount(amount); + return getAppointment(currentUser, item.getId()); + } + + private BigDecimal calculateOrderAmount(Long orderId) { + List items = orderItemMapper.selectList(new QueryWrapper() + .eq("order_id", orderId) + .eq("is_delete", 0)); + if (items == null || items.isEmpty()) { + throw new RuntimeException("订单没有可计算金额的项目"); + } + BigDecimal amount = BigDecimal.ZERO; + for (OrderItemDO orderItem : items) { + BigDecimal itemPrice = orderItem.getPrice() == null ? BigDecimal.ZERO : orderItem.getPrice(); + int quantity = Math.max(1, orderItem.getQuantity() == null ? 1 : orderItem.getQuantity()); + amount = amount.add(itemPrice.multiply(BigDecimal.valueOf(quantity))); + } + return amount; + } + @Override @Transactional public Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto) { @@ -381,14 +446,88 @@ public class PlanningServiceImpl implements PlanningService { int targetStatus = dto.getStatus(); if (targetStatus == OrderStatus.PENDING_SERVICE.getCode()) { if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())) { - orderMapper.updateStatusIfCurrent(order.getId(), order.getStatus(), OrderStatus.PENDING_SERVICE.getCode()); + int updated = orderMapper.updateStatusIfCurrent(order.getId(), order.getStatus(), OrderStatus.PENDING_SERVICE.getCode()); + if (updated == 0) { + throw new RuntimeException("订单状态已变化,请刷新后重试"); + } + order.setStatus(OrderStatus.PENDING_SERVICE.getCode()); } + restorePendingReservations(order); return true; } orderService.processOrder(orderId, targetStatus); return true; } + private void restorePendingReservations(OrderDO order) { + List items = orderItemMapper.selectList(new QueryWrapper() + .eq("order_id", order.getId()) + .eq("is_delete", 0)); + if (items == null || items.isEmpty()) { + throw new RuntimeException("订单没有可恢复的预约项目"); + } + for (OrderItemDO item : items) { + restorePendingReservation(order, item); + } + } + + private void restorePendingReservation(OrderDO order, OrderItemDO item) { + AppointmentReservationDO activeReservation = findActiveReservation(item.getId()); + if (activeReservation != null && RESERVATION_CONFIRMED.equals(activeReservation.getStatus())) { + return; + } + AppointmentReservationDO latestReservation = activeReservation == null ? findLatestReservation(item.getId()) : activeReservation; + if (item.getArtistId() == null) { + throw new RuntimeException("预约美甲师不能为空,无法恢复待完成状态"); + } + LocalDateTime startTime = item.getAppointmentTime() == null + ? latestReservation == null ? null : latestReservation.getAppointmentStartTime() + : item.getAppointmentTime(); + if (startTime == null) { + throw new RuntimeException("预约时间不能为空,无法恢复待完成状态"); + } + ProductDO product = item.getProductId() == null ? null : productMapper.selectById(item.getProductId()); + long durationMinutes = resolveRestoredDurationMinutes(latestReservation, item, product); + LocalDateTime endTime = startTime.plusMinutes(durationMinutes); + String productTitle = firstNonBlank( + latestReservation == null ? null : latestReservation.getProductTitle(), + resolveAppointmentDisplayTitle(null, item, product) + ); + if (activeReservation != null) { + appointmentCapacityService.confirmReservationOrThrow( + order.getId(), + item.getId(), + order.getShopId(), + item.getArtistId(), + productTitle, + startTime, + endTime + ); + return; + } + appointmentCapacityService.reserveConfirmedOrThrow( + order.getId(), + item.getId(), + order.getShopId(), + item.getArtistId(), + productTitle, + startTime, + endTime, + null + ); + } + + private long resolveRestoredDurationMinutes(AppointmentReservationDO reservation, OrderItemDO item, ProductDO product) { + if (reservation != null + && reservation.getAppointmentStartTime() != null + && reservation.getAppointmentEndTime() != null + && reservation.getAppointmentEndTime().isAfter(reservation.getAppointmentStartTime())) { + return Duration.between(reservation.getAppointmentStartTime(), reservation.getAppointmentEndTime()).toMinutes(); + } + int quantity = Math.max(1, item.getQuantity() == null ? 1 : item.getQuantity()); + return (long) resolveDurationMinutes(product, null) * quantity; + } + private Long requirePlanningShopId(UserDO currentUser) { Long shopId = adminScopeHelper.resolveShopScope(currentUser, null); if (shopId == null || shopId <= 0) { @@ -765,7 +904,7 @@ public class PlanningServiceImpl implements PlanningService { vo.setCanEdit(canEditAppointment(order, occupancyStatus)); vo.setCanCancel(canCancelAppointment(order, occupancyStatus)); vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus)); - vo.setAmount(order == null ? null : order.getActualAmount()); + vo.setAmount(resolveAppointmentAmount(item, order)); vo.setRemark(order == null ? null : order.getCustomerRemark()); vo.setProductDescription(resolveAppointmentProductDescription(item, product)); vo.setProductTags(resolveAppointmentProductTags(item, product)); @@ -775,6 +914,15 @@ public class PlanningServiceImpl implements PlanningService { return vo; } + private BigDecimal resolveAppointmentAmount(OrderItemDO item, OrderDO order) { + if (item == null) { + return order == null ? null : order.getActualAmount(); + } + BigDecimal price = item.getPrice() == null ? BigDecimal.ZERO : item.getPrice(); + int quantity = Math.max(1, item.getQuantity() == null ? 1 : item.getQuantity()); + return price.multiply(BigDecimal.valueOf(quantity)); + } + private List buildDaySummaries(LocalDate start, LocalDate end, List artists, List schedules, List appointments, ShopDO shop, Map shopExceptionByDate, @@ -1136,6 +1284,10 @@ public class PlanningServiceImpl implements PlanningService { return appointmentReservationMapper.selectOne(wrapper); } + private AppointmentReservationDO findLatestReservation(Long orderItemId) { + return appointmentReservationMapper.selectLatestByOrderItemIncludingDeleted(orderItemId); + } + private void ensureWithinBusinessHours(Long shopId, LocalDateTime startTime, LocalDateTime endTime) { ShopDO shop = shopMapper.selectById(shopId); List segments = splitAppointmentSegments(startTime, endTime); diff --git a/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/planning/service/impl/PlanningServiceImplTest.java b/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/planning/service/impl/PlanningServiceImplTest.java index e73ed4ba..f743c7db 100644 --- a/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/planning/service/impl/PlanningServiceImplTest.java +++ b/JY-Core/src/test/java/com/xiaowang/jayucloud/core/modules/planning/service/impl/PlanningServiceImplTest.java @@ -16,6 +16,8 @@ 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.PlanningAppointmentPriceDTO; +import com.xiaowang.jayucloud.core.modules.planning.dto.PlanningAppointmentStatusDTO; 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; @@ -558,6 +560,151 @@ class PlanningServiceImplTest { assertThat(appointment.getProductImageUrls()).containsExactly("https://img.example/601.jpg", "https://img.example/602.jpg"); } + @Test + void updateAppointmentPriceShouldPersistZeroAsPendingQuoteAmount() { + 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); + order.setTotalAmount(new BigDecimal("168.00")); + order.setActualAmount(new BigDecimal("168.00")); + order.setPayAmount(new BigDecimal("168.00")); + OrderItemDO item = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 13, 0)); + item.setAppointmentProductTitle("价格待定款"); + item.setPrice(new BigDecimal("168.00")); + OrderItemDO repricedItem = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 13, 0)); + repricedItem.setAppointmentProductTitle("价格待定款"); + repricedItem.setPrice(BigDecimal.ZERO); + OrderItemDO extraItem = orderItem(301L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 16, 0)); + extraItem.setQuantity(2); + extraItem.setPrice(new BigDecimal("30.00")); + PlanningAppointmentPriceDTO dto = new PlanningAppointmentPriceDTO(); + dto.setPrice(BigDecimal.ZERO); + AppointmentReservationDO reservation = reservation(20L, 200L, 300L, + LocalDateTime.of(2026, 7, 22, 13, 0), + LocalDateTime.of(2026, 7, 22, 14, 0)); + reservation.setProductTitle("价格待定款"); + + 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(orderItemMapper.update(any(OrderItemDO.class), any())).thenReturn(1); + when(orderItemMapper.selectList(any())).thenReturn(List.of(repricedItem, extraItem)); + when(orderMapper.update(any(OrderDO.class), any())).thenReturn(1); + when(userMapper.selectList(any())).thenReturn(List.of(artist)); + when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of()); + when(userMapper.selectBatchIds(any())).thenReturn(List.of(customer)); + + var appointment = planningService.updateAppointmentPrice(manager, 300L, dto); + + assertThat(item.getPrice()).isEqualByComparingTo("0"); + assertThat(order.getTotalAmount()).isEqualByComparingTo("60.00"); + assertThat(order.getActualAmount()).isEqualByComparingTo("60.00"); + assertThat(order.getPayAmount()).isEqualByComparingTo("60.00"); + ArgumentCaptor itemUpdateCaptor = ArgumentCaptor.forClass(OrderItemDO.class); + ArgumentCaptor orderUpdateCaptor = ArgumentCaptor.forClass(OrderDO.class); + org.mockito.Mockito.verify(orderItemMapper).update(itemUpdateCaptor.capture(), any()); + org.mockito.Mockito.verify(orderMapper).update(orderUpdateCaptor.capture(), any()); + assertThat(itemUpdateCaptor.getValue().getPrice()).isEqualByComparingTo("0"); + assertThat(orderUpdateCaptor.getValue().getTotalAmount()).isEqualByComparingTo("60.00"); + assertThat(orderUpdateCaptor.getValue().getActualAmount()).isEqualByComparingTo("60.00"); + assertThat(orderUpdateCaptor.getValue().getPayAmount()).isEqualByComparingTo("60.00"); + assertThat(appointment.getAmount()).isEqualByComparingTo("0"); + } + + @Test + void updateAppointmentPriceShouldRejectCompletedOrder() { + UserDO manager = user(2, 8L); + OrderDO order = order(200L, 8L, 30L); + order.setStatus(2); + OrderItemDO item = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 13, 0)); + PlanningAppointmentPriceDTO dto = new PlanningAppointmentPriceDTO(); + dto.setPrice(new BigDecimal("188.00")); + + when(orderItemMapper.selectByIdForUpdate(300L)).thenReturn(item); + when(orderMapper.selectById(200L)).thenReturn(order); + + assertThatThrownBy(() -> planningService.updateAppointmentPrice(manager, 300L, dto)) + .isInstanceOf(RuntimeException.class) + .hasMessageContaining("已完成或已取消的订单只可查看"); + } + + @Test + void updateStatusShouldRestoreReservationWhenCancelledOrderReturnsPendingService() { + UserDO manager = user(2, 8L); + OrderDO order = order(200L, 8L, 30L); + order.setStatus(3); + OrderItemDO item = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 15, 0)); + item.setAppointmentProductTitle("恢复预约"); + AppointmentReservationDO releasedReservation = reservation(20L, 200L, 300L, + LocalDateTime.of(2026, 7, 22, 15, 0), + LocalDateTime.of(2026, 7, 22, 16, 30)); + releasedReservation.setProductTitle("历史恢复预约"); + releasedReservation.setStatus("RELEASED"); + releasedReservation.setIsDelete(1); + PlanningAppointmentStatusDTO dto = new PlanningAppointmentStatusDTO(); + dto.setStatus(1); + + when(orderMapper.selectById(200L)).thenReturn(order); + when(orderMapper.updateStatusIfCurrent(200L, 3, 1)).thenReturn(1); + when(orderItemMapper.selectList(any())).thenReturn(List.of(item)); + when(appointmentReservationMapper.selectOne(any())).thenReturn(null); + when(appointmentReservationMapper.selectLatestByOrderItemIncludingDeleted(300L)).thenReturn(releasedReservation); + + Boolean updated = planningService.updateStatus(manager, 200L, dto); + + assertThat(updated).isTrue(); + org.mockito.Mockito.verify(appointmentCapacityService).reserveConfirmedOrThrow( + 200L, + 300L, + 8L, + 20L, + "历史恢复预约", + LocalDateTime.of(2026, 7, 22, 15, 0), + LocalDateTime.of(2026, 7, 22, 16, 30), + null + ); + } + + @Test + void updateStatusShouldConfirmActivePendingQuoteReservationWhenReturnsPendingService() { + UserDO manager = user(2, 8L); + OrderDO order = order(200L, 8L, 30L); + order.setStatus(0); + OrderItemDO item = orderItem(300L, 200L, null, 20L, LocalDateTime.of(2026, 7, 22, 15, 0)); + item.setAppointmentProductTitle("待确认恢复"); + AppointmentReservationDO activeReservation = reservation(20L, 200L, 300L, + LocalDateTime.of(2026, 7, 22, 15, 0), + LocalDateTime.of(2026, 7, 22, 16, 30)); + activeReservation.setProductTitle("待报价占用"); + activeReservation.setStatus("PENDING_QUOTE"); + PlanningAppointmentStatusDTO dto = new PlanningAppointmentStatusDTO(); + dto.setStatus(1); + + when(orderMapper.selectById(200L)).thenReturn(order); + when(orderMapper.updateStatusIfCurrent(200L, 0, 1)).thenReturn(1); + when(orderItemMapper.selectList(any())).thenReturn(List.of(item)); + when(appointmentReservationMapper.selectOne(any())).thenReturn(activeReservation); + + Boolean updated = planningService.updateStatus(manager, 200L, dto); + + assertThat(updated).isTrue(); + org.mockito.Mockito.verify(appointmentCapacityService).confirmReservationOrThrow( + 200L, + 300L, + 8L, + 20L, + "待报价占用", + LocalDateTime.of(2026, 7, 22, 15, 0), + LocalDateTime.of(2026, 7, 22, 16, 30) + ); + } + @Test void calendarMarksMonthAvailabilityByContinuousNinetyMinuteWindow() { UserDO manager = user(2, 8L); diff --git a/JY-Salon-WeChat/api/planning.js b/JY-Salon-WeChat/api/planning.js index 5808b078..94e71ba6 100644 --- a/JY-Salon-WeChat/api/planning.js +++ b/JY-Salon-WeChat/api/planning.js @@ -38,6 +38,21 @@ module.exports = { }) }, + updateAppointmentPrice(orderItemId, data) { + return request({ + url: `/manager/planning/appointments/${orderItemId}/price`, + method: 'PUT', + data + }) + }, + + signedImageUrl(fileId, expiryTimeInMinutes) { + return request({ + url: `/object-storage-file/get-signed-url/${fileId}`, + params: { expiryTimeInMinutes } + }) + }, + updateStatus(orderId, status) { return request({ url: `/manager/planning/appointments/${orderId}/status`, diff --git a/JY-Salon-WeChat/pages/appointment-detail/index.js b/JY-Salon-WeChat/pages/appointment-detail/index.js index fe1d2848..8bb3b7b8 100644 --- a/JY-Salon-WeChat/pages/appointment-detail/index.js +++ b/JY-Salon-WeChat/pages/appointment-detail/index.js @@ -2,6 +2,12 @@ const planningApi = require('../../api/planning') const { markPlanningRefresh } = require('../../utils/planning-refresh') const { chooseImageFilePaths, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload') +const MAX_APPOINTMENT_IMAGE_COUNT = 9 +const SIGNED_IMAGE_EXPIRE_MINUTES = 60 +const STATUS_PENDING_SERVICE = 1 +const STATUS_COMPLETED = 2 +const STATUS_CANCELLED = 3 + function canTransferAppointment() { const app = getApp() const userInfo = app.globalData.userInfo || {} @@ -15,11 +21,68 @@ function splitImageValues(value) { .filter(Boolean) } -function resolveProductImageUrls(appointment) { - if (appointment && Array.isArray(appointment.productImageUrls)) { - return appointment.productImageUrls.filter(Boolean) +function splitTagValues(value) { + return String(value || '') + .split(/[;,,、]/) + .map(item => item.trim()) + .filter(Boolean) +} + +function normalizeImageUrlArray(value) { + if (Array.isArray(value)) { + return value + .map(item => String(item || '').trim()) + .filter(Boolean) } - return [] + return splitImageValues(value) +} + +function resolveProductImageFileIds(appointment) { + if (!appointment || typeof appointment !== 'object') { + return [] + } + return splitImageValues(appointment.productImageFileIds || appointment.imageFileIds) +} + +function resolveProductImageUrls(appointment) { + if (!appointment || typeof appointment !== 'object') { + return [] + } + const productImageUrls = normalizeImageUrlArray(appointment.productImageUrls) + if (productImageUrls.length > 0) { + return productImageUrls + } + const imageUrls = normalizeImageUrlArray(appointment.imageUrls) + if (imageUrls.length > 0) { + return imageUrls + } + return normalizeImageUrlArray(appointment.productImageUrl || appointment.imageUrl) +} + +async function resolveSignedImageUrls(fileIds) { + const imageUrls = [] + for (let index = 0; index < fileIds.length; index += 1) { + const fileId = fileIds[index] + const signedUrl = await planningApi.signedImageUrl(fileId, SIGNED_IMAGE_EXPIRE_MINUTES) + const imageUrl = String(signedUrl || '').trim() + if (!imageUrl) { + throw new Error(`文件 ${fileId} 未返回可访问图片链接`) + } + imageUrls.push(imageUrl) + } + return imageUrls +} + +async function resolveDisplayImageUrls(appointment) { + const imageUrls = resolveProductImageUrls(appointment) + if (imageUrls.length > 0) { + return imageUrls + } + const fileIds = resolveProductImageFileIds(appointment) + if (fileIds.length === 0) { + return [] + } + return resolveSignedImageUrls(fileIds) } async function uploadAppointmentImageFiles(limit) { @@ -40,16 +103,133 @@ async function uploadAppointmentImageFiles(limit) { return { fileIds, imageUrls } } +function isPriceUndetermined(value) { + const amount = Number(value) + return Number.isFinite(amount) && amount === 0 +} + +function formatMoneyValue(value) { + const amount = Number(value) + if (!Number.isFinite(amount) || amount <= 0) { + return '' + } + return amount.toFixed(2).replace(/\.00$/, '') +} + +function formatAppointmentPrice(value) { + if (value === undefined || value === null || value === '' || isPriceUndetermined(value)) { + return '未定' + } + const moneyText = formatMoneyValue(value) + return moneyText ? `¥${moneyText}` : '未定' +} + +function sanitizePriceInput(value) { + const rawValue = String(value || '') + let nextValue = '' + let hasDot = false + for (let index = 0; index < rawValue.length; index += 1) { + const char = rawValue[index] + if (char >= '0' && char <= '9') { + nextValue += char + continue + } + if (char === '.' && !hasDot) { + nextValue += char + hasDot = true + } + } + if (nextValue.startsWith('.')) { + return `0${nextValue}` + } + return nextValue +} + +function normalizeConfirmedPrice(value) { + const priceText = sanitizePriceInput(value).trim() + if (!/^\d+(\.\d+)?$/.test(priceText)) { + return '' + } + const price = Number(priceText) + if (!Number.isFinite(price) || price < 0) { + return '' + } + return String(price) +} + +function buildPriceForm(amount) { + const pricePending = isPriceUndetermined(amount) + return { + pricePending, + priceText: pricePending ? '' : formatMoneyValue(amount) + } +} + +function buildDetailTags(appointment) { + const tags = [] + const productTags = splitTagValues(appointment && appointment.productTags) + for (let index = 0; index < productTags.length; index += 1) { + tags.push({ key: `product-${index}-${productTags[index]}`, label: productTags[index], type: 'product' }) + } + if (appointment && appointment.fromMeituan) { + tags.push({ key: 'source-meituan', label: '美团', type: 'source' }) + } + if (appointment && appointment.needRemoval) { + tags.push({ key: 'flag-need-removal', label: '需卸甲', type: 'warning' }) + } + if (appointment && appointment.depositPaid) { + tags.push({ key: 'flag-deposit-paid', label: '已交定金', type: 'paid' }) + } + if (appointment && isPriceUndetermined(appointment.amount)) { + tags.push({ key: 'flag-price-pending', label: '价格未定', type: 'price' }) + } + return tags +} + +function isAppointmentResponse(value) { + return value && typeof value === 'object' && (value.orderItemId || value.orderId) +} + +function confirmAction(title, content, confirmText, confirmColor) { + return new Promise((resolve, reject) => { + wx.showModal({ + title, + content, + cancelText: '取消', + confirmText, + confirmColor, + success(result) { + resolve(Boolean(result.confirm)) + }, + fail(error) { + reject(new Error(`打开确认弹窗失败:${error.errMsg || '未知错误'}`)) + } + }) + }) +} + Page({ data: { id: '', appointment: {}, avatarText: '', timeText: '', + priceText: '未定', + detailTags: [], productImageUrls: [], productImageFileIds: '', imageUploading: false, + canEditAppointment: false, canTransferAppointment: false, + showActionRow: false, + showPendingActions: false, + showRestoreAction: false, + priceModalVisible: false, + priceSaving: false, + priceForm: { + priceText: '', + pricePending: false + }, loadError: '' }, @@ -64,53 +244,95 @@ Page({ async loadDetail() { try { const appointment = await planningApi.appointment(this.data.id) - this.applyAppointment(appointment) + await this.applyAppointment(appointment) } catch (error) { this.setData({ appointment: {}, avatarText: '', timeText: '', + priceText: '未定', + detailTags: [], productImageUrls: [], productImageFileIds: '', + canEditAppointment: false, + showActionRow: false, + showPendingActions: false, + showRestoreAction: false, loadError: error.message || '预约详情加载失败' }) } }, - applyAppointment(appointment) { - const imageUrls = resolveProductImageUrls(appointment) + async applyAppointment(appointment) { + if (!appointment || typeof appointment !== 'object') { + throw new Error('预约详情数据为空') + } + const imageUrls = await resolveDisplayImageUrls(appointment) + const status = Number(appointment.status) + const showPendingActions = status === STATUS_PENDING_SERVICE + const showRestoreAction = status === STATUS_COMPLETED || status === STATUS_CANCELLED this.setData({ appointment, avatarText: String(appointment.customerName || '客').slice(0, 1), timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`, + priceText: formatAppointmentPrice(appointment.amount), + detailTags: buildDetailTags(appointment), productImageUrls: imageUrls, - productImageFileIds: String(appointment.productImageFileIds || ''), + productImageFileIds: resolveProductImageFileIds(appointment).join(','), + canEditAppointment: Boolean(appointment.canEdit), canTransferAppointment: canTransferAppointment(), + showActionRow: showPendingActions || showRestoreAction, + showPendingActions, + showRestoreAction, loadError: '' }) }, async updateStatus(status) { try { + if (!this.data.appointment.orderId) { + throw new Error('预约订单ID为空,无法修改状态') + } await planningApi.updateStatus(this.data.appointment.orderId, status) markPlanningRefresh() wx.showToast({ title: '已更新' }) - this.loadDetail() + await this.loadDetail() } catch (error) { wx.showToast({ title: error.message || '操作失败', icon: 'none' }) } }, - confirm() { - this.updateStatus(1) + async complete() { + try { + const confirmed = await confirmAction('完成预约', '确认将此预约标记为已完成?', '完成', '#6f8f83') + if (confirmed) { + await this.updateStatus(STATUS_COMPLETED) + } + } catch (error) { + wx.showToast({ title: error.message || '操作失败', icon: 'none' }) + } }, - complete() { - this.updateStatus(2) + async deleteAppointment() { + try { + const confirmed = await confirmAction('删除此订单', '确认删除此订单?删除后订单会进入已取消状态。', '删除', '#d98d8d') + if (confirmed) { + await this.updateStatus(STATUS_CANCELLED) + } + } catch (error) { + wx.showToast({ title: error.message || '操作失败', icon: 'none' }) + } }, - cancel() { - this.updateStatus(3) + async restorePending() { + try { + const confirmed = await confirmAction('修改状态', '确认将此预约改回待完成?', '修改', '#6f8f83') + if (confirmed) { + await this.updateStatus(STATUS_PENDING_SERVICE) + } + } catch (error) { + wx.showToast({ title: error.message || '操作失败', icon: 'none' }) + } }, goTransfer() { @@ -122,11 +344,15 @@ Page({ }, async persistAppointmentImages(fileIds, previewImageUrls) { - const appointment = await planningApi.updateAppointmentImages(this.data.id, { + const result = await planningApi.updateAppointmentImages(this.data.id, { imageFileIds: fileIds.join(',') }) markPlanningRefresh() - this.applyAppointment(appointment) + if (isAppointmentResponse(result)) { + await this.applyAppointment(result) + } else { + await this.loadDetail() + } if (Array.isArray(previewImageUrls) && previewImageUrls.length > 0) { this.setData({ productImageUrls: previewImageUrls }) } @@ -136,14 +362,22 @@ Page({ if (this.data.imageUploading) { return } + if (!this.data.canEditAppointment) { + wx.showToast({ title: '当前预约状态不可修改图片', icon: 'none' }) + return + } const currentFileIds = splitImageValues(this.data.productImageFileIds) - const remainingCount = 9 - currentFileIds.length + const remainingCount = MAX_APPOINTMENT_IMAGE_COUNT - currentFileIds.length if (remainingCount <= 0) { wx.showToast({ title: '最多上传 9 张作品图片', icon: 'none' }) return } - this.setData({ imageUploading: true }) try { + const confirmed = await confirmAction('上传图片', '确认添加作品图片到此预约?', '上传', '#6f8f83') + if (!confirmed) { + return + } + this.setData({ imageUploading: true }) const uploaded = await uploadAppointmentImageFiles(remainingCount) if (uploaded.fileIds.length === 0) { return @@ -160,39 +394,33 @@ Page({ } }, - 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, uploaded.imageUrls) - 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 } + if (!this.data.canEditAppointment) { + wx.showToast({ title: '当前预约状态不可删除图片', icon: 'none' }) + return + } const index = Number(event.currentTarget.dataset.index) const currentFileIds = splitImageValues(this.data.productImageFileIds) + if (currentFileIds.length === 0) { + wx.showToast({ title: '缺少图片文件ID,无法删除', icon: 'none' }) + return + } if (!Number.isInteger(index) || index < 0 || index >= currentFileIds.length) { + wx.showToast({ title: '图片序号无效,无法删除', icon: 'none' }) return } - const currentImageUrls = Array.isArray(this.data.productImageUrls) ? this.data.productImageUrls : [] - const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index) - const nextImageUrls = currentImageUrls.filter((item, itemIndex) => itemIndex !== index) - this.setData({ imageUploading: true }) try { + const confirmed = await confirmAction('删除图片', '确认删除这张作品图片?', '删除', '#d98d8d') + if (!confirmed) { + return + } + const currentImageUrls = Array.isArray(this.data.productImageUrls) ? this.data.productImageUrls : [] + const nextFileIds = currentFileIds.filter((item, itemIndex) => itemIndex !== index) + const nextImageUrls = currentImageUrls.filter((item, itemIndex) => itemIndex !== index) + this.setData({ imageUploading: true }) await this.persistAppointmentImages(nextFileIds, nextImageUrls) wx.showToast({ title: '图片已保存' }) } catch (error) { @@ -213,6 +441,86 @@ Page({ }) }, + openPriceEditor() { + if (this.data.priceSaving) { + return + } + if (!this.data.canEditAppointment) { + wx.showToast({ title: '当前预约状态不可修改价格', icon: 'none' }) + return + } + this.setData({ + priceModalVisible: true, + priceForm: buildPriceForm(this.data.appointment.amount) + }) + }, + + closePriceEditor() { + if (this.data.priceSaving) { + return + } + this.setData({ priceModalVisible: false }) + }, + + onPriceInput(event) { + const value = sanitizePriceInput(event.detail.value) + this.setData({ 'priceForm.priceText': value }) + return value + }, + + togglePricePending() { + if (this.data.priceSaving) { + return + } + const pricePending = !this.data.priceForm.pricePending + const patch = { + 'priceForm.pricePending': pricePending + } + if (pricePending) { + patch['priceForm.priceText'] = '' + } + this.setData(patch) + }, + + async savePrice() { + if (this.data.priceSaving) { + return + } + const form = this.data.priceForm + const priceText = form.pricePending ? '0' : normalizeConfirmedPrice(form.priceText) + if (!priceText) { + wx.showToast({ title: '请填写正确的价格', icon: 'none' }) + return + } + const price = Number(priceText) + const priceLabel = price === 0 ? '未定' : `¥${formatMoneyValue(price)}` + try { + const confirmed = await confirmAction('保存价格', `确认将本次价格保存为${priceLabel}?`, '保存', '#6f8f83') + if (!confirmed) { + return + } + this.setData({ priceSaving: true }) + const result = await planningApi.updateAppointmentPrice(this.data.id, { + price + }) + markPlanningRefresh() + if (isAppointmentResponse(result)) { + await this.applyAppointment(result) + } else { + await this.loadDetail() + } + this.setData({ priceModalVisible: false }) + wx.showToast({ title: '价格已保存' }) + } catch (error) { + wx.showToast({ title: error.message || '价格保存失败', icon: 'none' }) + } finally { + this.setData({ priceSaving: false }) + } + }, + + stopTap() { + }, + back() { wx.navigateBack() } diff --git a/JY-Salon-WeChat/pages/appointment-detail/index.wxml b/JY-Salon-WeChat/pages/appointment-detail/index.wxml index d1c1d6ce..1a0ff78f 100644 --- a/JY-Salon-WeChat/pages/appointment-detail/index.wxml +++ b/JY-Salon-WeChat/pages/appointment-detail/index.wxml @@ -15,14 +15,23 @@ {{appointment.statusText}} - + + {{item.label}} + 项目 {{appointment.productTitle}} + + 价格 + + {{priceText}} + + + 美甲师 {{appointment.artistName}} @@ -41,19 +50,21 @@ 作品图片 - - × + × - + {{imageUploading ? '...' : '+'}} - 暂无图片 + + {{imageUploading ? '上传中...' : '暂无图片'}} + + @@ -62,9 +73,33 @@ {{appointment.remark || '暂无备注'}} - - - - + + + + 修改价格 + × + + + {{priceForm.pricePending ? '✓' : ''}} + 价格未定 + + + 本次价格 + + + 元 + + + + + + + + + + + + + diff --git a/JY-Salon-WeChat/pages/appointment-detail/index.wxss b/JY-Salon-WeChat/pages/appointment-detail/index.wxss index d34a54c2..2edee704 100644 --- a/JY-Salon-WeChat/pages/appointment-detail/index.wxss +++ b/JY-Salon-WeChat/pages/appointment-detail/index.wxss @@ -72,6 +72,45 @@ margin-top: 28rpx; } +.detail-tag-row { + display: flex; + flex-wrap: wrap; + gap: 10rpx; + margin-top: 22rpx; +} + +.detail-tag { + display: inline-flex; + align-items: center; + min-height: 40rpx; + padding: 0 16rpx; + border-radius: 999rpx; + background: #f0ece5; + color: #6d675f; + font-size: 22rpx; + font-weight: 700; +} + +.detail-tag.source { + background: #e8f2f7; + color: #4c7890; +} + +.detail-tag.warning { + background: #fff0e2; + color: #b36a34; +} + +.detail-tag.paid { + background: #e8f3ec; + color: #5b8067; +} + +.detail-tag.price { + background: #f5e8e8; + color: #a75353; +} + .label, .value { display: block; @@ -89,6 +128,37 @@ font-weight: 700; } +.price-value-row { + display: flex; + align-items: center; + min-width: 0; + gap: 12rpx; + margin-top: 8rpx; +} + +.price-value { + flex: 1; + min-width: 0; + margin-top: 0; +} + +.price-edit-btn { + display: inline-flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + width: 82rpx; + min-width: 82rpx; + max-width: 82rpx; + height: 42rpx; + min-height: 42rpx; + border-radius: 999rpx; + background: #e5eee9; + color: #55786d; + font-size: 22rpx; + font-weight: 800; +} + .note-card { padding: 24rpx; color: #6d655d; @@ -102,15 +172,6 @@ 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; } @@ -173,8 +234,10 @@ .detail-image-empty { display: flex; + flex-direction: column; align-items: center; justify-content: center; + gap: 14rpx; min-height: 142rpx; border-radius: 16rpx; background: #f7efe7; @@ -182,12 +245,153 @@ font-size: 26rpx; } +.image-empty-action { + min-height: 48rpx; + font-size: 24rpx; +} + +.detail-modal-mask { + position: fixed; + inset: 0; + z-index: 30; + display: flex; + align-items: flex-end; + justify-content: center; + padding: 24rpx; + background: rgba(32, 27, 22, 0.34); +} + +.price-modal { + width: 100%; + max-width: 680rpx; + padding: 26rpx; + border-radius: 24rpx 24rpx 16rpx 16rpx; + background: #fffdf8; + box-shadow: 0 -12rpx 34rpx rgba(58, 48, 34, 0.12); +} + +.price-modal-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 20rpx; +} + +.price-modal-title { + color: #2d2924; + font-size: 30rpx; + font-weight: 900; +} + +.price-modal-close { + display: flex; + align-items: center; + justify-content: center; + width: 52rpx; + height: 52rpx; + border-radius: 50%; + background: #f0ece5; + color: #6d655d; + font-size: 32rpx; + font-weight: 700; + line-height: 52rpx; +} + +.price-pending-option { + display: flex; + align-items: center; + gap: 14rpx; + min-height: 76rpx; + margin-top: 24rpx; + padding: 0 18rpx; + border: 1rpx solid #eee2d5; + border-radius: 16rpx; + background: #fff8ef; + color: #554c44; + font-size: 26rpx; + font-weight: 800; +} + +.price-pending-option.active { + border-color: #7d9d90; + background: #edf6f1; + color: #55786d; +} + +.price-pending-check { + display: flex; + align-items: center; + justify-content: center; + flex: 0 0 auto; + width: 34rpx; + height: 34rpx; + border: 2rpx solid #d5c6b8; + border-radius: 50%; + color: #55786d; + font-size: 22rpx; + font-weight: 900; +} + +.price-pending-option.active .price-pending-check { + border-color: #7d9d90; + background: #dfeee7; +} + +.price-field { + margin-top: 20rpx; +} + +.price-field.disabled { + opacity: 0.55; +} + +.price-field-label { + display: block; + margin-bottom: 10rpx; + color: #625c55; + font-size: 24rpx; + font-weight: 800; +} + +.price-input-wrap { + display: flex; + align-items: center; + height: 76rpx; + padding: 0 18rpx; + border-radius: 16rpx; + background: #fffaf4; +} + +.price-input-wrap input { + flex: 1; + min-width: 0; + color: #2d2924; + font-size: 28rpx; +} + +.price-input-wrap text { + flex: 0 0 auto; + color: #9a9288; + font-size: 24rpx; +} + +.price-modal-actions { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 14rpx; + margin-top: 28rpx; +} + .action-row { display: grid; - grid-template-columns: 1fr 1fr 1fr; + grid-template-columns: 1fr 1fr; gap: 14rpx; } +.action-row.single { + grid-template-columns: 1fr; +} + .action-row .primary-btn, .action-row .secondary-btn, .action-row .danger-btn { diff --git a/JY-Salon-WeChat/pages/appointment-form/index.js b/JY-Salon-WeChat/pages/appointment-form/index.js index 121b2dc2..2d295178 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.js +++ b/JY-Salon-WeChat/pages/appointment-form/index.js @@ -7,6 +7,7 @@ const { markPlanningRefresh } = require('../../utils/planning-refresh') const { chooseImageFilePaths, uploadObjectFile, resolveUploadedImagePreviewUrl } = require('../../utils/upload') const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft' +const PLANNING_RETURN_TARGET_STORAGE_KEY = 'planningReturnTarget' const TIME_SLOT_MINUTES = 15 const DAY_MINUTES = 24 * 60 const DAY_END_COVER_MINUTE = 23 * 60 + 59 @@ -146,6 +147,41 @@ function removeDraftForm() { } } +function writePlanningReturnTarget(target) { + try { + wx.setStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY, target) + } catch (error) { + throw new Error(`写入规划页返回目标失败:${error.message || error}`) + } +} + +function confirmAppointmentSubmit() { + return new Promise((resolve, reject) => { + wx.showModal({ + title: '确认提交预约', + content: '提交成功后将返回规划月视图。', + confirmText: '提交', + cancelText: '再检查', + success: result => resolve(!!result.confirm), + fail: error => reject(new Error(`打开预约确认弹窗失败:${error.errMsg || error.message || error}`)) + }) + }) +} + +function confirmFormAction(title, content, confirmText, confirmColor) { + return new Promise((resolve, reject) => { + wx.showModal({ + title, + content, + cancelText: '取消', + confirmText, + confirmColor, + success: result => resolve(!!result.confirm), + fail: error => reject(new Error(`打开确认弹窗失败:${error.errMsg || error.message || error}`)) + }) + }) +} + function normalizeDuration(value) { const duration = Number(value) return Number.isFinite(duration) && duration > 0 ? Math.floor(duration) : 0 @@ -440,12 +476,16 @@ function normalizeProduct(product, artists) { .map(id => findArtist(artists, id).name) .filter(Boolean) const durationText = product.approximateDuration || (product.serviceDurationMinutes ? `${product.serviceDurationMinutes}分钟` : '') + const productPrice = formatProductPrice(product.price) + const productPriceText = productPrice === '0' + ? '未定' + : productPrice ? `¥${productPrice}` : '价格待定' return { ...product, coverImage: imageUrls[0] || '', tagList: parseProductTags(product).slice(0, 4), artistText: artistNames.length > 0 ? artistNames.join('、') : '全部美甲师', - priceText: product.price || product.price === 0 ? `¥${product.price}` : '价格待定', + priceText: productPriceText, durationText } } @@ -553,8 +593,11 @@ function normalizeConfirmedPrice(value) { return String(price) } -function collectManualProductImages(fileIds, imageUrls) { - return splitManualImageValues(`${fileIds || ''},${imageUrls || ''}`) +function resolveAppointmentPriceText(form) { + if (form.manualProductPriceUndetermined) { + return '0' + } + return normalizeConfirmedPrice(form.manualProductPrice) } function normalizeCustomer(customer) { @@ -606,6 +649,7 @@ Page({ productId: '', manualProductTitle: '', manualProductPrice: '', + manualProductPriceUndetermined: false, manualProductDescription: '', manualProductTags: '', manualProductPrecautions: '', @@ -740,6 +784,9 @@ Page({ const patch = { [`form.${field}`]: value } + if (field === 'manualProductPrice' && value) { + patch['form.manualProductPriceUndetermined'] = false + } if (field === 'customerName' || field === 'phone') { patch['form.customerUserId'] = '' patch.customerDropdownVisible = true @@ -762,6 +809,17 @@ Page({ }) }, + onPriceUndeterminedChange(event) { + const checked = !!event.detail.value + const patch = { + 'form.manualProductPriceUndetermined': checked + } + if (checked) { + patch['form.manualProductPrice'] = '' + } + this.setData(patch) + }, + onCustomerFocus(event) { const field = event.currentTarget.dataset.field this.setData({ @@ -919,13 +977,15 @@ Page({ selectProduct(event) { const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(event.currentTarget.dataset.id)) || {} const price = formatProductPrice(selectedProduct.price) + const priceUndetermined = price === '' || price === '0' const productTag = resolveTagValue(this.data.tagOptions, parseProductTags(selectedProduct).join(',')) const imageUrls = Array.isArray(selectedProduct.imageUrls) ? selectedProduct.imageUrls : [] this.setData({ selectedProduct, 'form.productId': '', 'form.manualProductTitle': selectedProduct.title || '', - 'form.manualProductPrice': price, + 'form.manualProductPrice': priceUndetermined ? '' : price, + 'form.manualProductPriceUndetermined': priceUndetermined, 'form.manualProductDescription': selectedProduct.description || '', 'form.manualProductTags': productTag, 'form.manualProductPrecautions': selectedProduct.precautions || '', @@ -953,8 +1013,8 @@ Page({ useManualProduct() { const title = String(this.data.form.manualProductTitle || '').trim() - const priceText = normalizeConfirmedPrice(this.data.form.manualProductPrice) - const imageValues = collectManualProductImages(this.data.form.manualProductImageFileIds, this.data.form.manualProductImageUrl) + const priceUndetermined = !!this.data.form.manualProductPriceUndetermined + const priceText = resolveAppointmentPriceText(this.data.form) if (!title) { wx.showToast({ title: '请填写作品名称', icon: 'none' }) return @@ -963,15 +1023,11 @@ Page({ wx.showToast({ title: '请填写正确的作品价格', icon: 'none' }) return } - if (imageValues.length === 0) { - wx.showToast({ title: '请上传作品图片', icon: 'none' }) - return - } this.setData({ selectedProduct: {}, 'form.productId': '', 'form.manualProductTitle': title, - 'form.manualProductPrice': priceText, + 'form.manualProductPrice': priceUndetermined ? '' : priceText, manualProductPanelVisible: false }) this.closeProductModal() @@ -1225,7 +1281,7 @@ Page({ return } const form = this.data.form - const hasManualProduct = String(form.manualProductTitle || '').trim() && String(form.manualProductPrice || '').trim() + const hasManualProduct = String(form.manualProductTitle || '').trim() const customerName = String(form.customerName || '').trim() const phone = String(form.phone || '').trim() const durationMinutes = normalizeDuration(form.durationMinutes) @@ -1233,17 +1289,12 @@ Page({ wx.showToast({ title: '请补全预约信息', icon: 'none' }) return } - const appointmentPriceText = normalizeConfirmedPrice(form.manualProductPrice) + const appointmentPriceText = resolveAppointmentPriceText(form) if (!appointmentPriceText) { wx.showToast({ title: '请填写本次价格', icon: 'none' }) return } const appointmentPrice = Number(appointmentPriceText) - const manualProductImages = collectManualProductImages(form.manualProductImageFileIds, form.manualProductImageUrl) - if (!form.productId && manualProductImages.length === 0) { - wx.showToast({ title: '请上传作品图片', icon: 'none' }) - return - } if (!durationMinutes) { wx.showToast({ title: '请填写预约时长', icon: 'none' }) return @@ -1253,6 +1304,16 @@ Page({ wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' }) return } + let confirmed + try { + confirmed = await confirmAppointmentSubmit() + } catch (error) { + wx.showToast({ title: error.message || '确认提交失败', icon: 'none' }) + return + } + if (!confirmed) { + return + } this.setData({ loading: true }) try { const payload = { @@ -1267,6 +1328,7 @@ Page({ durationMinutes, clientRequestId: buildClientRequestId('manager-appointment') } + delete payload.manualProductPriceUndetermined if (form.productId) { payload.productId = String(form.productId) payload.manualProductTitle = undefined @@ -1282,8 +1344,16 @@ Page({ } const result = await planningApi.createAppointment(payload) removeDraftForm() + writePlanningReturnTarget({ + source: 'appointment-create', + date: form.appointmentDate, + orderItemId: result.orderItemId || result.id || '' + }) markPlanningRefresh() - wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` }) + wx.switchTab({ + url: '/pages/planning/index', + fail: error => wx.showToast({ title: `跳转规划页失败:${error.errMsg || error.message || error}`, icon: 'none' }) + }) } catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { @@ -1301,7 +1371,17 @@ Page({ } }, - clearDraft() { + async clearDraft() { + let confirmed + try { + confirmed = await confirmFormAction('清空草稿', '确认清空当前本机预约草稿?', '清空', '#d98d8d') + } catch (error) { + wx.showToast({ title: error.message || '确认清空失败', icon: 'none' }) + return + } + if (!confirmed) { + return + } try { removeDraftForm() this.setData({ draftSavedAtText: '' }) diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxml b/JY-Salon-WeChat/pages/appointment-form/index.wxml index 7b59d21d..2bc64041 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.wxml +++ b/JY-Salon-WeChat/pages/appointment-form/index.wxml @@ -5,10 +5,6 @@ 客户姓名 - - 手机号 - - 正在搜索客户... {{customerError}},可继续手动输入 @@ -36,10 +32,18 @@ {{form.customerName ? (form.manualProductTitle || selectedProduct.title || '请选择作品') : '请先填写客户姓名'}} - - 本次价格 - - 元 + + 本次价格 + + + + {{form.manualProductPriceUndetermined ? '未定' : '元'}} + + + 价格未定 + + + 预计时长 @@ -110,16 +114,20 @@ - 价格 - - - 元 + 价格 + + + {{form.manualProductPriceUndetermined ? '未定' : '元'}} + + + 价格未定 + - 作品图片 + 作品图片 @@ -155,10 +163,8 @@ - - 使用已有作品模板 - × + 选择已有作品 diff --git a/JY-Salon-WeChat/pages/appointment-form/index.wxss b/JY-Salon-WeChat/pages/appointment-form/index.wxss index be33519c..10ec605b 100644 --- a/JY-Salon-WeChat/pages/appointment-form/index.wxss +++ b/JY-Salon-WeChat/pages/appointment-form/index.wxss @@ -35,6 +35,67 @@ font-size: 24rpx; } +.price-field { + align-items: flex-start; +} + +.price-control { + display: flex; + min-width: 0; + flex: 1; + flex-direction: column; + gap: 12rpx; +} + +.price-input, +.manual-price-input { + display: flex; + align-items: center; + min-height: 72rpx; + padding-right: 16rpx; + border: 1rpx solid #eadfd2; + border-radius: 18rpx; + background: #fffdf8; +} + +.price-input.disabled, +.manual-price-input.disabled { + background: #f5f0ea; + color: #9a9288; +} + +.form-card .price-input input { + min-height: 70rpx; + padding: 0 18rpx; + border: 0; + border-radius: 0; + background: transparent; +} + +.price-input text, +.manual-price-input text { + flex: 0 0 auto; + color: #9a9288; + font-size: 22rpx; +} + +.price-toggle, +.manual-price-toggle { + display: flex; + align-items: center; + justify-content: flex-end; + gap: 8rpx; + color: #6d6258; + font-size: 24rpx; + font-weight: 800; +} + +.price-toggle switch, +.manual-price-toggle switch { + transform: scale(0.72); + transform-origin: right center; +} + .customer-select { position: relative; } @@ -45,7 +106,7 @@ .customer-dropdown { position: absolute; - top: 214rpx; + top: 102rpx; right: 0; left: 180rpx; z-index: 30; @@ -927,7 +988,7 @@ .manual-field-row { display: grid; - grid-template-columns: minmax(0, 1fr) 200rpx; + grid-template-columns: minmax(0, 1fr) 248rpx; gap: 14rpx; } @@ -958,27 +1019,13 @@ font-size: 26rpx; } -.manual-price-input { - display: flex; - align-items: center; - height: 70rpx; - padding-right: 16rpx; - border-radius: 14rpx; - background: #fffaf4; -} - .manual-price-input input { flex: 1; width: auto; min-width: 0; padding-right: 8rpx; background: transparent; -} - -.manual-price-input text { - flex: 0 0 auto; - color: #9a9288; - font-size: 22rpx; + border: 0; } .manual-field picker { diff --git a/JY-Salon-WeChat/pages/planning/index.js b/JY-Salon-WeChat/pages/planning/index.js index 71cf98b1..43c1d242 100644 --- a/JY-Salon-WeChat/pages/planning/index.js +++ b/JY-Salon-WeChat/pages/planning/index.js @@ -3,6 +3,7 @@ const shopApi = require('../../api/shop') const dateUtil = require('../../utils/date') const { markPlanningRefresh } = require('../../utils/planning-refresh') +const PLANNING_RETURN_TARGET_STORAGE_KEY = 'planningReturnTarget' const CALENDAR_ERROR_FALLBACK_MESSAGE = '规划数据暂时不可用,请稍后重试' const TECHNICAL_ERROR_PATTERNS = [ /###\s*Error/i, @@ -28,6 +29,42 @@ function resolveCalendarErrorMessage(error) { return hasTechnicalMessage ? CALENDAR_ERROR_FALLBACK_MESSAGE : message } +function readPlanningReturnTarget() { + try { + const target = wx.getStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY) + return target && typeof target === 'object' ? target : null + } catch (error) { + throw new Error(`读取规划页返回目标失败:${error.message || error}`) + } +} + +function removePlanningReturnTarget() { + try { + wx.removeStorageSync(PLANNING_RETURN_TARGET_STORAGE_KEY) + } catch (error) { + throw new Error(`清理规划页返回目标失败:${error.message || error}`) + } +} + +function confirmPlanningAction(title, content, confirmText, confirmColor) { + return new Promise((resolve, reject) => { + wx.showModal({ + title, + content, + cancelText: '取消', + confirmText, + confirmColor, + success: result => resolve(Boolean(result.confirm)), + fail: error => reject(new Error(`打开确认弹窗失败:${error.errMsg || error.message || error}`)) + }) + }) +} + +function normalizeReturnTargetDate(value) { + const dateText = String(value || '').slice(0, 10) + return /^\d{4}-\d{2}-\d{2}$/.test(dateText) ? dateText : dateUtil.formatDate(new Date()) +} + function toLocalDate(value) { return value instanceof Date ? new Date(value.getTime()) : new Date(String(value).replace(/-/g, '/')) } @@ -119,6 +156,24 @@ function appointmentStatusClass(status) { return '' } +function resolveAppointmentItemId(item) { + if (!item) { + return '' + } + return item.orderItemId || item.id ? String(item.orderItemId || item.id) : '' +} + +function resolveAppointmentEventId(event) { + const currentDataset = event && event.currentTarget && event.currentTarget.dataset ? event.currentTarget.dataset : {} + const targetDataset = event && event.target && event.target.dataset ? event.target.dataset : {} + return currentDataset.orderItemId || currentDataset.id || targetDataset.orderItemId || targetDataset.id || '' +} + +function hasAppointmentDataset(dataset) { + return Object.prototype.hasOwnProperty.call(dataset, 'orderItemId') + || Object.prototype.hasOwnProperty.call(dataset, 'id') +} + function completedOrCancelledClass(status) { if (isCompletedStatus(status)) return 'is-completed' if (isCancelledStatus(status)) return 'is-cancelled' @@ -233,6 +288,31 @@ Page({ onShow() { const app = getApp() + try { + const returnTarget = readPlanningReturnTarget() + if (returnTarget) { + removePlanningReturnTarget() + const targetDate = normalizeReturnTargetDate(returnTarget.date) + this._needRefresh = false + app.globalData.planningNeedRefresh = false + wx.removeStorageSync('planningNeedRefresh') + this.setData({ + viewMode: 'month', + currentDate: toLocalDate(targetDate), + currentDateText: targetDate, + emptyDateActionVisible: false, + pendingEmptyDate: '', + pendingEmptyDateTitle: '', + pendingEmptyDateLabel: '', + savingSpecialDate: false + }) + this.prepareView() + this.loadCalendar() + return + } + } catch (error) { + wx.showToast({ title: error.message || '读取规划返回目标失败', icon: 'none' }) + } const storageRefresh = wx.getStorageSync('planningNeedRefresh') === '1' if (this._needRefresh || app.globalData.planningNeedRefresh || storageRefresh) { this._needRefresh = false @@ -267,6 +347,10 @@ Page({ }, selectDate(event) { + const targetDataset = event && event.target && event.target.dataset ? event.target.dataset : {} + if (hasAppointmentDataset(targetDataset)) { + return + } const currentDate = dateUtil.formatDate(event.currentTarget.dataset.date) if (this.data.viewMode === 'month') { const monthDay = this.data.monthDays.find(item => item.date === currentDate) @@ -384,6 +468,8 @@ Page({ async loadCalendar() { const range = this.resolveRange() + const requestSeq = (this._calendarRequestSeq || 0) + 1 + this._calendarRequestSeq = requestSeq this.setData({ loading: true }) try { const data = await planningApi.calendar({ @@ -392,9 +478,15 @@ Page({ artistId: this.data.selectedArtistId || undefined }) const shopSchedule = await this.loadShopSchedule(range) + if (requestSeq !== this._calendarRequestSeq) { + return + } this.applyCalendar(data, shopSchedule) this.setData({ calendarError: '' }) } catch (error) { + if (requestSeq !== this._calendarRequestSeq) { + return + } this.clearCalendarView() this.setData({ calendarError: resolveCalendarErrorMessage(error), @@ -406,7 +498,9 @@ Page({ icon: 'none' }) } finally { - this.setData({ loading: false }) + if (requestSeq === this._calendarRequestSeq) { + this.setData({ loading: false }) + } } }, @@ -522,8 +616,8 @@ Page({ dayStatus: summary.dayStatus || 'free', shopRest: shopRestDates.includes(day.date), artistCounts, - expandedBlocks: this.buildExpandedBlocks(artistCounts), - rowBlocks: this.buildRowBlocks(artistCounts), + expandedBlocks: dayAppointments.length ? this.buildAppointmentBlocks(dayAppointments, 'block') : this.buildExpandedBlocks(artistCounts), + rowBlocks: dayAppointments.length ? this.buildAppointmentBlocks(dayAppointments, 'row') : this.buildRowBlocks(artistCounts), statusClass: resolveDayStatusClass(dayAppointments) } }) @@ -575,8 +669,11 @@ Page({ .filter(item => String(item.artistId) === String(artist.id)) .map(item => { const itemStart = resolveAppointmentStartMinute(item) + const orderItemId = resolveAppointmentItemId(item) return { ...item, + id: orderItemId, + orderItemId, top: Math.max(0, itemStart - startMinute) + laneHeaderHeight, height: Math.max(82, item.durationMinutes || 60), timeText: resolveAppointmentTimeText(item), @@ -611,6 +708,28 @@ Page({ return (this.data.appointments || []).filter(item => resolveAppointmentDate(item) === date) }, + buildAppointmentBlocks(appointments, mode) { + const artistMap = (this.data.artists || []).reduce((map, artist) => { + map[String(artist.id)] = artist + return map + }, {}) + return (appointments || []).map((item, index) => { + const artist = artistMap[String(item.artistId)] || {} + const artistName = item.artistName || artist.name || '' + const orderItemId = resolveAppointmentItemId(item) + return { + key: `${mode}-${orderItemId || item.artistId || 'appointment'}-${index}`, + id: orderItemId, + orderItemId, + artistId: item.artistId, + color: item.color || artist.color || '#B8B0A6', + shortName: artist.shortName || String(artistName || '?').slice(0, 1), + artistName: artistName || '?', + statusClass: completedOrCancelledClass(item.status) + } + }) + }, + appointmentCountsByDate(date) { const artistMap = (this.data.artists || []).reduce((map, artist) => { map[String(artist.id)] = artist @@ -621,15 +740,17 @@ Page({ const artist = artistMap[String(item.artistId)] || {} const artistName = item.artistName || artist.name const statusClass = completedOrCancelledClass(item.status) - const key = `${String(item.artistId || item.orderItemId)}-${statusClass || 'active'}` + const orderItemId = resolveAppointmentItemId(item) + const key = `${String(item.artistId || orderItemId)}-${statusClass || 'active'}` const existing = grouped.get(key) if (existing) { grouped.set(key, { ...existing, count: existing.count + 1 }) } else { grouped.set(key, { key: `${key}-${index}`, - orderItemId: item.orderItemId, - artistId: item.artistId || item.orderItemId, + id: orderItemId, + orderItemId, + artistId: item.artistId || orderItemId, artistName, shortName: artist.shortName || String(artistName || '?').slice(0, 1), color: artist.color || '#B8B0A6', @@ -649,8 +770,11 @@ Page({ }, {}) return (counts || []).map(count => { const artist = colorMap[count.artistId] || {} + const orderItemId = count.orderItemId || count.id || '' return { ...count, + id: orderItemId, + orderItemId, key: `${String(count.artistId)}-${count.status || 'summary'}`, color: count.color || artist.color || '#B8B0A6', shortName: count.shortName || artist.shortName || '?', @@ -662,8 +786,11 @@ Page({ buildExpandedBlocks(artistCounts) { return (artistCounts || []).reduce((blocks, count) => { for (let index = 0; index < Number(count.count || 0); index += 1) { + const orderItemId = count.orderItemId || count.id || '' blocks.push({ key: count.key ? `${count.key}-${index}` : `${count.artistId || count.shortName}-${index}`, + id: orderItemId, + orderItemId, artistId: count.artistId, color: count.color, shortName: count.shortName, @@ -677,8 +804,11 @@ Page({ buildRowBlocks(artistCounts) { return (artistCounts || []).reduce((rows, count) => { for (let index = 0; index < Number(count.count || 0); index += 1) { + const orderItemId = count.orderItemId || count.id || '' rows.push({ key: count.key ? `${count.key}-row-${index}` : `${count.artistId || count.shortName}-row-${index}`, + id: orderItemId, + orderItemId, artistId: count.artistId, color: count.color, shortName: count.shortName, @@ -730,6 +860,16 @@ Page({ wx.showToast({ title: '请设置正确营业时间', icon: 'none' }) return } + let confirmed + try { + confirmed = await confirmPlanningAction('保存特殊日期', `确认将 ${this.data.pendingEmptyDate} 设置为${option.label}?`, '保存', '#6f8f83') + } catch (error) { + wx.showToast({ title: error.message || '确认保存失败', icon: 'none' }) + return + } + if (!confirmed) { + return + } this.setData({ savingSpecialDate: true }) try { await shopApi.saveScheduleException({ @@ -751,8 +891,25 @@ Page({ }, openAppointment(event) { + const currentDataset = event && event.currentTarget && event.currentTarget.dataset ? event.currentTarget.dataset : {} + const count = Number(currentDataset.count || 1) + if (this.data.viewMode === 'month' && this.data.monthDisplayMode === 'count' && count > 1) { + const date = normalizeReturnTargetDate(currentDataset.date) + this.setData({ + currentDate: toLocalDate(date), + currentDateText: date, + monthDisplayMode: 'blocks' + }) + wx.showToast({ title: '请点击具体预约块查看详情', icon: 'none' }) + return + } + const id = resolveAppointmentEventId(event) + if (!id) { + wx.showToast({ title: '缺少预约详情ID', icon: 'none' }) + return + } wx.navigateTo({ - url: `/pages/appointment-detail/index?id=${event.currentTarget.dataset.id}` + url: `/pages/appointment-detail/index?id=${encodeURIComponent(id)}` }) } }) diff --git a/JY-Salon-WeChat/pages/planning/index.wxml b/JY-Salon-WeChat/pages/planning/index.wxml index f6d4a4af..262c48e1 100644 --- a/JY-Salon-WeChat/pages/planning/index.wxml +++ b/JY-Salon-WeChat/pages/planning/index.wxml @@ -63,7 +63,7 @@ {{item.name}} - + {{block.customerName}} {{block.timeText}} · {{block.productTitle}} @@ -129,19 +129,19 @@ 满 - - {{count.shortName}}{{count.count}} + + {{count.shortName}}{{count.count}} 空 - + 空 - - {{block.artistName}} + + {{block.artistName}} 空 diff --git a/memory/bugs.md b/memory/bugs.md index 4367fe47..3ea6f519 100644 --- a/memory/bugs.md +++ b/memory/bugs.md @@ -320,3 +320,35 @@ - 处理方式:资产表摘要必须按表头白名单选择字段,只允许输出名称、角色、IP、端口、中心、承载形态、状态来源等字段;输出前再断言结果不包含账号、密码、token、密钥、连接命令或已打码凭据片段。 - 以后避免:生产资产清单扫描默认使用“字段名白名单 + 输出敏感词断言”,不要用“敏感表头出现后取几个固定列”的方式。 - 验证方式:摘要脚本输出前执行敏感词扫描,命中时直接失败并改写脚本,不把候选输出打印到终端。 + +## 2026-07-23 预约恢复历史占用不能用逻辑删除实体查询 + +- 问题:店务预约已取消后恢复为待完成时,如果用 MyBatis-Plus 对带 `@TableLogic` 的预约占用实体执行普通 `selectOne`,可能读不到 `is_delete=1` 的历史释放记录,导致恢复时长退回默认 60 分钟。 +- 原因:逻辑删除插件会自动附加未删除过滤条件,普通 Wrapper 不适合读取“包含已删除”的历史记录。 +- 处理方式:在 Mapper 中增加显式 SQL `selectLatestByOrderItemIncludingDeleted`,按 `order_item_id` 查询最新历史记录,不依赖逻辑删除实体查询。 +- 以后避免:凡是要读取逻辑删除表的历史/审计/恢复记录,必须使用明确包含已删除语义的 Mapper 方法或经验证的忽略逻辑删除机制。 +- 验证方式:单测构造 `is_delete=1` 的释放预约记录,恢复状态时应按历史预约的结束时间和标题重新占用;运行 `PlanningServiceImplTest`。 + +## 2026-07-23 小程序可见需求不能漏暂存 WXML + +- 问题:店务小程序预约表单已经改了 JS/CSS,但承载手机号栏位移除、价格未定开关、非必填星号的 `index.wxml` 一度仍是未暂存状态,提交会漏掉可见需求。 +- 原因:分阶段暂存时只看已暂存 stat,未同步核对同一页面的 WXML/JS/WXSS 三件套是否成组进入提交。 +- 处理方式:提交前用 `git status --short` 和 `git diff --name-only` 对照需求清单,确认页面结构、逻辑和样式文件都进入本次暂存。 +- 以后避免:小程序 UI 需求只要涉及页面字段、按钮或弹窗,必须检查 `.wxml`、`.js`、`.wxss` 是否完整暂存,不只看逻辑文件。 +- 验证方式:暂存后执行 `git diff --cached --name-only`,确认本次页面三件套齐全;再运行 JS 语法检查和 `git diff --cached --check`。 + +## 2026-07-23 小程序写操作确认弹窗要覆盖次级入口 + +- 问题:预约详情上传图片、规划页空日期快速保存特殊日期、预约表单清空草稿这类次级写操作容易漏掉二次确认。 +- 原因:只关注完成、删除订单、保存价格等主按钮,忽略会修改服务端状态或丢失本机输入的辅助入口。 +- 处理方式:凡是会提交接口、改变预约/排班状态、删除图片或清空本机草稿的入口,都先统一走 `wx.showModal` 确认。 +- 以后避免:搜索页面内的 `save`、`update`、`delete`、`remove`、`clear`、上传和状态接口调用,逐个判断是否需要确认,不只凭按钮文案判断。 +- 验证方式:代码检索写操作入口均有确认分支;小程序 JS 语法检查、`git diff --check` 通过。 + +## 2026-07-23 GitNexus 全局启动器可能仍使用旧 Node + +- 问题:即使显式使用 `E:\Development\Node\node-v24\node.exe` 执行 `.gitnexus/run.cjs`,本机全局 `gitnexus.ps1` 仍可能调用 `E:\Development\Node\npm-global\node.exe`,触发 `diagChan.tracingChannel is not a function`。 +- 原因:项目 runner 会优先落到全局 `gitnexus` 启动器;该启动器如果同目录存在旧版 `node.exe`,会绕开当前 shell 里的 Node v24。 +- 处理方式:直接用 Node v24 执行全局 CLI JS:`E:\Development\Node\node-v24\node.exe E:\Development\Node\npm-global\node_modules\gitnexus\dist\cli\index.js detect-changes --scope staged -r JayuCloud`。 +- 以后避免:GitNexus 命令出现 `diagChan.tracingChannel` 时,先检查启动器实际使用的 Node,不要只检查外层 `node -v`。 +- 验证方式:`status` 和 `detect-changes --scope staged -r JayuCloud` 能正常返回仓库状态、变更文件数、影响流程和风险等级。 diff --git a/memory/progress.md b/memory/progress.md index 89f9cf14..412c7ab9 100644 --- a/memory/progress.md +++ b/memory/progress.md @@ -2,21 +2,21 @@ ## 当前任务 -生产 Core 更新与员工全周全天排班 SQL 执行。 +店务端小程序预约新需求:新建预约流程、规划页跳转、预约详情展示/操作与后端状态/价格修改能力。 ## 已完成 -- 已读取项目规则、轻量记忆、SQL 迭代规则和错误记忆相关条目。 -- 已确认本次生产范围只更新 `JY-Core.jar` 和员工全周全天排班刷数 SQL,不更新 Gateway、Nacos、Nginx、网页静态资源和小程序。 -- 已完成 `JY-Core` 打包、SQL 结构测试和后端目标测试。 -- 已从生产 Nacos 配置库脱敏解析 datasource,确认目标为 `192.168.5.110:3306/jayu_cloud`。 -- 已在生产写库执行员工全周全天排班刷数 SQL,验证缺失规则数从 2 变为 0。 -- 已更新三台生产 Core 的 `/opt/jayu-cloud/core/JY-Core.jar` 与 `/opt/jayu-cloud/core/app.jar`,三台服务均为 `active`,本机和公网健康检查通过。 -- 已将生产执行后的 SQL 文件追加 `_生产已执行` 后缀,并补充项目变更记录与测试验收记录。 +- 已读取项目规则、轻量记忆和错误记忆相关条目。 +- 已确认用户采用并发修改方案,并按互不重叠写入范围启动后端、表单/规划页、详情页三个子线程。 +- 已复核本次不涉及 SQL 迁移,暂不修改初始化 SQL 或新增迁移脚本。 +- 已完成后端价格修改接口、状态回退恢复预约占用、小程序新建预约表单、规划页回跳与详情页展示/操作优化。 +- 已根据并发复核补齐详情上传图片、规划特殊日期保存、清空草稿的二次确认,并处理月视图聚合多单点击分流。 +- 已收紧详情价格修改:已完成/已取消不可直接改价,预约详情金额改为当前预约项目金额,整单金额按项目重新汇总。 +- 已通过 `PlanningServiceImplTest`、小程序页面 JS 语法检查、`git diff --check` 和 GitNexus staged `detect-changes`。 ## 下一步 -- 运行提交前检查,删除临时部署脚本,只提交本次生产执行记录相关文件。 +- 重新暂存最新记忆文件后提交,提交信息使用中文。 ## 当前阻塞点 @@ -24,4 +24,4 @@ ## 最近一次重要操作结果 -2026-07-22 21:50 生产 `JY-core01`、`JY-core02`、`JY-core03` 均已更新到 SHA-256 `c82484d487cd27191a433622eb5f775317c62214794d8d9e85f00c0952ee1bbb`;员工全周全天排班 SQL 在生产库验证 `missing_rules=0`;公网 `https://yunail.art/health/check` 与 `https://yunail.art/api/shop/list` 均返回 200。 +2026-07-23 01:31 目标后端测试通过:`PlanningServiceImplTest` 18 个用例全部通过;小程序 `appointment-detail`、`appointment-form`、`planning` 页面 JS 语法检查通过,`git diff --check` 通过;GitNexus staged `detect-changes` 返回 low risk、0 affected processes。