新增历史补单与服务中状态

This commit is contained in:
2026-10-13 12:36:01 +08:00
parent 3ab615ccd4
commit bd8d95fcd9
29 changed files with 294 additions and 29 deletions
@@ -53,7 +53,7 @@ public class OperationsAnalyticsServiceImpl implements OperationsAnalyticsServic
vo.setCartCount(0L);
vo.setOrderCount((long) orders.size());
vo.setPaidOrderCount(orders.stream().filter(order -> "PAID".equals(order.getPaymentStatus())).count());
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
vo.setCompletedOrderCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus()) || Integer.valueOf(4).equals(order.getStatus())).count());
vo.setReviewCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
.eq(UserGrowthRecordDO::getSourceType, "REVIEW")));
vo.setRebookCount(userGrowthRecordMapper.selectCount(new LambdaQueryWrapper<UserGrowthRecordDO>()
@@ -53,7 +53,7 @@ public class WorkbenchServiceImpl implements WorkbenchService {
vo.setLowStockItemCount(countLowStock(shopId));
vo.setScheduleReminderCount(countMissingSchedules(shopId, artistId, todayStart.toLocalDate()));
vo.setTodayServiceCount(countTodayServices(artistId, todayStart, tomorrowStart));
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus())).count());
vo.setCompletedServiceCount(orders.stream().filter(order -> Integer.valueOf(2).equals(order.getStatus()) || Integer.valueOf(4).equals(order.getStatus())).count());
vo.setServiceAmount(orders.stream()
.map(order -> order.getActualAmount() == null ? BigDecimal.ZERO : order.getActualAmount())
.reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -18,6 +18,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.manager.dto.ManagerCustomerCrea
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.service.PlanningService;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
@@ -89,6 +90,15 @@ public class AdminManagerController {
return Result.success(planningService.createAppointment(currentUser, dto));
}
@PostMapping("/planning/backfill-orders")
@RequirePermission("order:process")
@OperationGuard(action = "manager-planning-create-backfill-order", ttlSeconds = 10, message = "补单创建处理中,请勿重复提交")
public Result<PlanningAppointmentVO> createBackfillOrder(HttpServletRequest request,
@RequestBody PlanningBackfillOrderCreateDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(planningService.createBackfillOrder(currentUser, dto));
}
@GetMapping("/planning/appointments/{orderItemId}")
@RequirePermission("order:view")
public Result<PlanningAppointmentVO> appointment(HttpServletRequest request,
@@ -54,7 +54,10 @@ public class OrderDO extends BaseEntity {
private String paymentOrderNo;
private String refundStatus;
private String customerRemark;
private String customerNameSnapshot;
private String customerPhoneSnapshot;
private String quoteStatus;
private String orderSource;
private Integer quoteUserConfirmed;
private Integer quoteShopConfirmed;
private LocalDateTime quoteExpireTime;
@@ -44,6 +44,7 @@ public class OrderItemDO extends BaseEntity {
* Field `appointmentTime` (LocalDateTime): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
*/
private LocalDateTime appointmentTime;
private java.time.LocalDate serviceDate;
/**
* Field `createTime` (LocalDateTime): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
@@ -1519,7 +1519,7 @@ public class OrderServiceImpl implements OrderService {
*/
throw new RuntimeException("订单不存在");
}
if (status != 2 && status != 3) {
if (status != 2 && status != 3 && status != 4) {
/**
* Run business method `RuntimeException`.
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
@@ -1528,7 +1528,13 @@ public class OrderServiceImpl implements OrderService {
throw new RuntimeException("无效的订单状态");
}
OrderStatus targetStatus = OrderStatus.requireKnown(status);
if (status == OrderStatus.IN_SERVICE.getCode()
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())) {
throw new RuntimeException("普通预约不能进入服务中状态");
}
if (!Integer.valueOf(OrderStatus.PENDING_SERVICE.getCode()).equals(order.getStatus())
&& !(Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())
&& (status == OrderStatus.COMPLETED.getCode() || status == OrderStatus.CANCELLED.getCode()))
&& !(Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(order.getStatus())
&& Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(status))) {
/**
@@ -3278,6 +3284,9 @@ public class OrderServiceImpl implements OrderService {
if (Integer.valueOf(3).equals(status)) {
return "已取消";
}
if (Integer.valueOf(4).equals(status)) {
return "服务中";
}
return "未知状态";
}
@@ -3327,6 +3336,7 @@ public class OrderServiceImpl implements OrderService {
orderVO.setCustomerNickname(resolveCustomerNickname(customer));
orderVO.setCustomerPhoneMasked(maskPhone(customer == null ? null : customer.getPhone()));
orderVO.setStatus(order.getStatus());
orderVO.setOrderSource(order.getOrderSource());
switch (order.getStatus()) {
case 0:
@@ -3341,6 +3351,9 @@ public class OrderServiceImpl implements OrderService {
case 3:
orderVO.setStatusText("已取消");
break;
case 4:
orderVO.setStatusText("服务中");
break;
default:
orderVO.setStatusText("未知状态");
}
@@ -3395,6 +3408,8 @@ public class OrderServiceImpl implements OrderService {
itemVO.setPrice(displayPrice);
itemVO.setTotalPrice(displayPrice.multiply(BigDecimal.valueOf(item.getQuantity())));
itemVO.setAppointmentTime(formatAppointmentTime(item.getAppointmentTime()));
itemVO.setServiceDate(item.getServiceDate() == null ? null : item.getServiceDate().toString());
itemVO.setHistoricalBackfill("HISTORICAL_BACKFILL".equals(order.getOrderSource()));
String occupancyStatus = resolveOrderItemOccupancyStatus(order);
itemVO.setOccupancyStatus(occupancyStatus);
itemVO.setCanEdit(canEditOrderItem(order));
@@ -3453,6 +3468,9 @@ public class OrderServiceImpl implements OrderService {
if (Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(order.getStatus())) {
return "COMPLETED";
}
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus())) {
return "HISTORICAL_BACKFILL";
}
return "UNKNOWN";
}
@@ -19,7 +19,10 @@ public final class OrderStateMachine {
if (from == OrderStatus.PRICE_CONFIRMING) {
return to == OrderStatus.PENDING_SERVICE || to == OrderStatus.CANCELLED;
}
return from == OrderStatus.PENDING_SERVICE
if (from == OrderStatus.PENDING_SERVICE) {
return to == OrderStatus.COMPLETED || to == OrderStatus.CANCELLED;
}
return from == OrderStatus.IN_SERVICE
&& (to == OrderStatus.COMPLETED || to == OrderStatus.CANCELLED);
}
@@ -10,7 +10,8 @@ public enum OrderStatus {
PRICE_CONFIRMING(0),
PENDING_SERVICE(1),
COMPLETED(2),
CANCELLED(3);
CANCELLED(3),
IN_SERVICE(4);
/**
* Purpose: code supports OrderStatus.java by holding or executing the code business role.
@@ -57,6 +57,8 @@ public class OrderItemVO {
* Field `appointmentTime` (String): data variable carried by this DTO/VO/entity. Check controller/service usage to see when it is filled.
*/
private String appointmentTime;
private String serviceDate;
private Boolean historicalBackfill;
private String occupancyStatus;
private Boolean canEdit;
private Boolean canCancel;
@@ -66,6 +66,7 @@ public class OrderVO {
private String refundStatus;
private String customerRemark;
private String quoteStatus;
private String orderSource;
private String quoteStatusText;
private Boolean quoteUserConfirmed;
private Boolean quoteShopConfirmed;
@@ -4,6 +4,7 @@ import com.xiaowang.jacyucloudsalon.core.annotation.OperationGuard;
import com.xiaowang.jacyucloudsalon.core.annotation.RequirePermission;
import com.xiaowang.jacyucloudsalon.core.common.Result;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
@@ -53,6 +54,15 @@ public class AdminPlanningController {
return Result.success(planningService.createAppointment(currentUser, dto));
}
@PostMapping("/backfill-orders")
@RequirePermission("order:process")
@OperationGuard(action = "admin-planning-create-backfill-order", ttlSeconds = 10, message = "补单创建处理中,请勿重复提交")
public Result<PlanningAppointmentVO> createBackfillOrder(HttpServletRequest request,
@RequestBody PlanningBackfillOrderCreateDTO dto) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(planningService.createBackfillOrder(currentUser, dto));
}
@GetMapping("/appointments/{orderItemId}")
@RequirePermission("order:view")
public Result<PlanningAppointmentVO> appointment(HttpServletRequest request,
@@ -0,0 +1,21 @@
package com.xiaowang.jacyucloudsalon.core.modules.planning.dto;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PlanningBackfillOrderCreateDTO {
private Long productId;
private String manualProductTitle;
private BigDecimal manualProductPrice;
private Long customerUserId;
private String customerName;
private String phone;
private String serviceDate;
private String serviceTime;
private Long artistId;
private BigDecimal amount;
private Integer status;
private String remark;
}
@@ -1,6 +1,7 @@
package com.xiaowang.jacyucloudsalon.core.modules.planning.service;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
@@ -17,6 +18,8 @@ public interface PlanningService {
PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto);
PlanningAppointmentVO createBackfillOrder(UserDO currentUser, PlanningBackfillOrderCreateDTO dto);
PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId);
PlanningAppointmentVO moveAppointment(UserDO currentUser, Long orderItemId, PlanningAppointmentMoveDTO dto);
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentMoveDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningBackfillOrderCreateDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.entity.AppointmentReservationDO;
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleDO;
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleExceptionDO;
@@ -198,6 +199,7 @@ public class PlanningServiceImpl implements PlanningService {
order.setPayAmount(amount);
order.setPaidAmount(BigDecimal.ZERO);
order.setStatus(OrderStatus.PENDING_SERVICE.getCode());
order.setOrderSource("NORMAL_APPOINTMENT");
order.setIsDelete(0);
orderMapper.insert(order);
@@ -227,6 +229,56 @@ public class PlanningServiceImpl implements PlanningService {
return getAppointment(currentUser, item.getId());
}
@Override
@Transactional
public PlanningAppointmentVO createBackfillOrder(UserDO currentUser, PlanningBackfillOrderCreateDTO dto) {
if (dto == null) throw new RuntimeException("补单信息不能为空");
if (Integer.valueOf(3).equals(currentUser.getType())) throw new RuntimeException("美甲师账号不能创建补单");
Long shopId = requirePlanningShopId(currentUser);
if (!hasText(dto.getServiceDate())) throw new RuntimeException("服务日期不能为空");
LocalDate serviceDate;
try { serviceDate = LocalDate.parse(dto.getServiceDate()); }
catch (DateTimeParseException ex) { throw new RuntimeException("服务日期格式不正确"); }
UserDO artist = requireActiveArtist(dto.getArtistId(), shopId);
ProductDO product;
if (dto.getProductId() != null) product = requireActiveProduct(dto.getProductId(), shopId);
else {
String title = trimToNull(dto.getManualProductTitle());
if (!hasText(title)) throw new RuntimeException("请选择项目或填写项目名称");
BigDecimal price = dto.getManualProductPrice() == null ? dto.getAmount() : dto.getManualProductPrice();
if (price == null || price.compareTo(BigDecimal.ZERO) < 0) throw new RuntimeException("项目金额不能小于0");
product = new ProductDO(); product.setShopId(shopId); product.setTitle(title); product.setPrice(price);
product.setSourceType(PRODUCT_SOURCE_TYPE_MANAGER_APPOINTMENT); product.setFrontVisible(0);
product.setLikeCount(0); product.setCollectCount(0); product.setIsDelete(0); productMapper.insert(product);
}
if (dto.getAmount() == null || dto.getAmount().compareTo(BigDecimal.ZERO) < 0) throw new RuntimeException("金额不能为空且不能小于0");
int status = dto.getStatus() == null ? OrderStatus.COMPLETED.getCode() : dto.getStatus();
if (status != OrderStatus.IN_SERVICE.getCode() && status != OrderStatus.COMPLETED.getCode()) throw new RuntimeException("补单状态只能为服务中或已完成");
UserDO customer = null;
if (dto.getCustomerUserId() != null) {
customer = userMapper.selectById(dto.getCustomerUserId());
if (customer == null || Integer.valueOf(1).equals(customer.getIsDelete())) throw new RuntimeException("客户不存在");
}
LocalDateTime appointmentTime = null;
if (hasText(dto.getServiceTime())) {
try { appointmentTime = LocalDateTime.of(serviceDate, LocalTime.parse(dto.getServiceTime())); }
catch (DateTimeParseException ex) { throw new RuntimeException("服务时间格式不正确"); }
}
OrderDO order = new OrderDO(); order.setOrderNo("ORD" + snowflakeIdGenerator.nextIdString());
order.setUserId(customer == null ? null : customer.getId()); order.setShopId(shopId);
order.setTotalAmount(dto.getAmount()); order.setActualAmount(dto.getAmount()); order.setPayAmount(dto.getAmount());
order.setPaidAmount(dto.getAmount()); order.setPaymentStatus("PAID"); order.setQuoteStatus("CONFIRMED");
order.setQuoteUserConfirmed(1); order.setQuoteShopConfirmed(1); order.setQuoteConfirmedTime(LocalDateTime.now());
order.setStatus(status); order.setOrderSource("HISTORICAL_BACKFILL"); order.setCustomerRemark(trimToNull(dto.getRemark()));
order.setCustomerNameSnapshot(trimToNull(dto.getCustomerName()));
order.setCustomerPhoneSnapshot(trimToNull(dto.getPhone()));
order.setIsDelete(0); orderMapper.insert(order);
OrderItemDO item = new OrderItemDO(); item.setOrderId(order.getId()); item.setProductId(product.getId());
item.setQuantity(1); item.setPrice(dto.getAmount()); item.setArtistId(artist.getId()); item.setServiceDate(serviceDate);
item.setAppointmentTime(appointmentTime); item.setIsDelete(0); orderItemMapper.insert(item);
return getAppointment(currentUser, item.getId());
}
@Override
public PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId) {
if (orderItemId == null) {
@@ -241,7 +293,7 @@ public class PlanningServiceImpl implements PlanningService {
AppointmentReservationDO reservation = findActiveReservation(orderItemId);
Map<Long, PlanningArtistVO> artistMap = listArtists(order.getShopId(), item.getArtistId()).stream()
.collect(Collectors.toMap(PlanningArtistVO::getId, Function.identity(), (a, b) -> a));
Map<Long, UserDO> customerMap = loadUsers(Set.of(order.getUserId()));
Map<Long, UserDO> customerMap = order.getUserId() == null ? Map.of() : loadUsers(Set.of(order.getUserId()));
return toAppointmentVO(reservation, item, order, product, customerMap.get(order.getUserId()), artistMap);
}
@@ -406,9 +458,9 @@ public class PlanningServiceImpl implements PlanningService {
QueryWrapper<OrderItemDO> itemWrapper = new QueryWrapper<>();
itemWrapper.eq("is_delete", 0)
.isNotNull("appointment_time")
.ge("appointment_time", rangeStart)
.lt("appointment_time", rangeEnd)
.and(wrapper -> wrapper
.and(q -> q.isNotNull("appointment_time").ge("appointment_time", rangeStart).lt("appointment_time", rangeEnd))
.or(q -> q.isNotNull("service_date").ge("service_date", rangeStart.toLocalDate()).lt("service_date", rangeEnd.toLocalDate())))
.orderByAsc("appointment_time");
if (artistId != null && artistId > 0) {
itemWrapper.eq("artist_id", artistId);
@@ -508,18 +560,20 @@ public class PlanningServiceImpl implements PlanningService {
vo.setOrderNo(order == null ? null : order.getOrderNo());
vo.setOrderItemId(item == null ? reservation == null ? null : reservation.getOrderItemId() : item.getId());
vo.setCustomerId(customer == null ? order == null ? null : order.getUserId() : customer.getId());
vo.setCustomerName(customer == null ? "到店客户" : firstNonBlank(customer.getNickname(), customer.getAccount(), "到店客户"));
vo.setCustomerPhone(customer == null ? null : firstNonBlank(customer.getContactPhone(), customer.getPhone(), ""));
vo.setCustomerName(customer == null ? firstNonBlank(order == null ? null : order.getCustomerNameSnapshot(), "散客") : firstNonBlank(customer.getNickname(), customer.getAccount(), "到店客户"));
vo.setCustomerPhone(customer == null ? order == null ? null : order.getCustomerPhoneSnapshot() : 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.setArtistId(artistId);
boolean unassigned = artistId == null;
vo.setArtistName(unassigned ? "待分配" : artist.getName());
vo.setArtistColor(unassigned ? "#D59A52" : artist.getColor());
vo.setArtistName(unassigned ? "待分配" : artist == null ? "美甲师" : artist.getName());
vo.setArtistColor(unassigned ? "#D59A52" : artist == null ? "#7BA7C7" : artist.getColor());
vo.setAssignmentStatus(unassigned ? RESERVATION_UNASSIGNED : ASSIGNMENT_ASSIGNED);
vo.setDate(start == null ? null : start.toLocalDate().toString());
vo.setHistoricalBackfill(order != null && "HISTORICAL_BACKFILL".equals(order.getOrderSource()));
LocalDate serviceDate = item == null ? null : item.getServiceDate();
vo.setDate(start == null ? serviceDate == null ? null : serviceDate.toString() : start.toLocalDate().toString());
vo.setStartTime(start == null ? null : DATE_TIME_FORMATTER.format(start));
vo.setEndTime(end == null ? null : DATE_TIME_FORMATTER.format(end));
vo.setStartMinute(start == null ? null : start.toLocalTime().toSecondOfDay() / 60);
@@ -527,7 +581,7 @@ public class PlanningServiceImpl implements PlanningService {
vo.setStatus(order == null ? null : order.getStatus());
vo.setStatusText(statusText(order == null ? null : order.getStatus()));
String occupancyStatus = unassigned ? RESERVATION_UNASSIGNED : resolveOccupancyStatus(reservation, order);
vo.setOccupancyStatus(occupancyStatus);
vo.setOccupancyStatus(Boolean.TRUE.equals(vo.getHistoricalBackfill()) ? "HISTORICAL_BACKFILL" : occupancyStatus);
vo.setCanEdit(canEditAppointment(order, occupancyStatus));
vo.setCanCancel(canCancelAppointment(order, occupancyStatus));
vo.setConflictReason(resolveAppointmentConflictReason(occupancyStatus));
@@ -866,12 +920,18 @@ public class PlanningServiceImpl implements PlanningService {
if (Integer.valueOf(OrderStatus.COMPLETED.getCode()).equals(status)) {
return "已完成";
}
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(status)) {
return "服务中";
}
if (Integer.valueOf(OrderStatus.CANCELLED.getCode()).equals(status)) {
return "已取消";
}
if (Integer.valueOf(OrderStatus.PRICE_CONFIRMING.getCode()).equals(status)) {
return "待确认";
}
if (Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(status)) {
return "服务中";
}
return "未知";
}
@@ -896,6 +956,7 @@ public class PlanningServiceImpl implements PlanningService {
private Boolean canEditAppointment(OrderDO order, String occupancyStatus) {
return order != null
&& !"HISTORICAL_BACKFILL".equals(order.getOrderSource())
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus)
|| RESERVATION_CONFIRMED.equals(occupancyStatus)
|| RESERVATION_UNASSIGNED.equals(occupancyStatus))
@@ -905,6 +966,7 @@ public class PlanningServiceImpl implements PlanningService {
private Boolean canCancelAppointment(OrderDO order, String occupancyStatus) {
return order != null
&& (!"HISTORICAL_BACKFILL".equals(order.getOrderSource()) || Integer.valueOf(OrderStatus.IN_SERVICE.getCode()).equals(order.getStatus()))
&& (RESERVATION_PENDING_QUOTE.equals(occupancyStatus)
|| RESERVATION_CONFIRMED.equals(occupancyStatus)
|| RESERVATION_UNASSIGNED.equals(occupancyStatus))
@@ -18,6 +18,7 @@ public class PlanningAppointmentVO {
private String artistName;
private String artistColor;
private String assignmentStatus;
private Boolean historicalBackfill;
private String date;
private String startTime;
private String endTime;
@@ -34,7 +34,7 @@ const formatMoney = (value?: number | string) => {
const formatDateTime = (value?: string) => value ? String(value).replace('T', ' ').slice(0, 16) : '--'
const isQuoteStatus = (status?: unknown) => Number(status) === 0
const isQuoteConfirming = computed(() => isQuoteStatus(order.value?.status))
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : 'pending'
const statusClass = (status?: number) => isQuoteStatus(status) ? 'quote' : status === 2 ? 'done' : status === 3 ? 'cancelled' : status === 4 ? 'in-service' : 'pending'
const isOrderPaid = (target: any) => String(target?.paymentStatus || '').toUpperCase() === 'PAID'
const canPreparePayment = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && !isOrderPaid(order.value))
const canMockPay = computed(() => !isQuoteConfirming.value && Number(order.value?.status) === 1 && String(order.value?.paymentStatus || '').toUpperCase() === 'PAYING')
@@ -31,7 +31,7 @@ const nodes = computed(() => {
{ key: 'created', title: '订单创建', desc: formatTime(current.createTime), done: true, active: false },
{ key: 'appointment', title: '预约确认', desc: formatTime(firstAppointment.value), done: Boolean(firstAppointment.value), active: status === 1 },
{ key: 'artist', title: '服务安排', desc: latestChangeText.value, done: changes.value.length > 0 || items.value.some((item: any) => item.artistName), active: changes.value.some(item => item.status === 'PENDING') },
{ key: 'service', title: status === 3 ? '订单取消' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 },
{ key: 'service', title: status === 3 ? '订单取消' : status === 4 ? '服务中' : '服务完成', desc: formatTime(current.completeTime || current.cancelTime || current.updateTime), done: status === 2 || status === 3, active: status === 2 || status === 3 || status === 4 },
{ key: 'after-sale', title: '售后/评价', desc: afterSales.value.length ? `${afterSales.value.length} 条售后` : (reviews.value.length ? `${reviews.value.length} 条评价` : '暂无记录'), done: afterSales.value.length > 0 || reviews.value.length > 0, active: afterSales.value.some(item => item.status === 'PENDING') || reviews.value.some(item => !item.rating) }
]
})
@@ -108,6 +108,22 @@
>
取消订单
</a-button>
<a-button
v-if="record.status === 4 && canProcessOrders"
type="primary"
size="small"
@click="process(record.id, 2)"
>
完成补单
</a-button>
<a-button
v-if="record.status === 4 && canProcessOrders && !isArtist"
danger
size="small"
@click="process(record.id, 3)"
>
取消补单
</a-button>
</a-space>
</template>
</template>
@@ -175,6 +191,8 @@
>
取消
</a-button>
<a-button v-if="item.status === 4 && canProcessOrders" size="small" type="primary" @click="process(item.id, 2)">完成补单</a-button>
<a-button v-if="item.status === 4 && canProcessOrders && !isArtist" size="small" danger @click="process(item.id, 3)">取消补单</a-button>
</div>
</article>
</template>
@@ -195,6 +213,7 @@
<a-descriptions-item label="实付金额">{{ formatMoney(currentOrder.actualAmount) }}</a-descriptions-item>
<a-descriptions-item label="优惠券">{{ currentOrder.couponName || '无' }}</a-descriptions-item>
<a-descriptions-item label="订单状态">{{ orderStatusText(currentOrder) }}</a-descriptions-item>
<a-descriptions-item label="订单来源">{{ currentOrder.orderSource === 'HISTORICAL_BACKFILL' ? '历史补单' : '正常订单' }}</a-descriptions-item>
<a-descriptions-item label="创建时间" :span="isMobile ? 1 : 2">{{ currentOrder.createTime }}</a-descriptions-item>
</a-descriptions>
@@ -496,7 +515,8 @@ const statusOptions = [
{ label: '待报价', value: '0' },
{ label: '待完成', value: '1' },
{ label: '已完成', value: '2' },
{ label: '已取消', value: '3' }
{ label: '已取消', value: '3' },
{ label: '服务中', value: '4' }
]
const activeFilterCount = computed(() => [
@@ -623,6 +643,7 @@ const statusColor = (status: number) => {
if (normalized === 1) return 'orange'
if (normalized === 2) return 'green'
if (normalized === 3) return 'red'
if (normalized === 4) return 'processing'
return 'default'
}
+8
View File
@@ -22,6 +22,14 @@ module.exports = {
})
},
createBackfillOrder(data) {
return request({
url: '/manager/planning/backfill-orders',
method: 'POST',
data
})
},
appointment(orderItemId) {
return request({
url: `/manager/planning/appointments/${orderItemId}`
+1
View File
@@ -5,6 +5,7 @@
"pages/register/index",
"pages/planning/index",
"pages/appointment-form/index",
"pages/backfill-order/index",
"pages/appointment-detail/index",
"pages/artist-transfer/index",
"pages/customers/index",
@@ -35,7 +35,7 @@ Page({
appointment,
isUnassigned: appointment.assignmentStatus === 'UNASSIGNED' || !appointment.artistId,
avatarText: String(appointment.customerName || '客').slice(0, 1),
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
timeText: appointment.historicalBackfill && !appointment.startTime ? '时间未记录' : `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
loadError: ''
})
},
@@ -56,6 +56,7 @@ Page({
},
confirm() {
if (this.data.appointment.historicalBackfill) return
this.updateStatus(1)
},
@@ -68,6 +69,7 @@ Page({
},
goTransfer() {
if (this.data.appointment.historicalBackfill) return
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
},
@@ -14,8 +14,9 @@
</view>
</view>
<view class="detail-actions">
<text class="tag">{{appointment.statusText}}</text>
<button class="small-action" bindtap="goTransfer">{{isUnassigned ? '分配员工' : '改派'}}</button>
<text wx:if="{{appointment.historicalBackfill}}" class="tag">历史补单 · {{appointment.statusText}}</text>
<text wx:else class="tag">{{appointment.statusText}}</text>
<button wx:if="{{!appointment.historicalBackfill}}" class="small-action" bindtap="goTransfer">{{isUnassigned ? '分配员工' : '改派'}}</button>
</view>
</view>
<view class="detail-grid">
@@ -44,8 +45,8 @@
</view>
<view wx:if="{{!loadError}}" class="fixed-bottom action-row">
<button class="secondary-btn" disabled="{{isUnassigned}}" bindtap="confirm">{{isUnassigned ? '待分配' : '确认'}}</button>
<button class="primary-btn" disabled="{{isUnassigned}}" bindtap="complete">完成</button>
<button wx:if="{{!appointment.historicalBackfill}}" class="secondary-btn" disabled="{{isUnassigned}}" bindtap="confirm">{{isUnassigned ? '待分配' : '确认'}}</button>
<button class="primary-btn" disabled="{{isUnassigned}}" bindtap="complete">{{appointment.historicalBackfill ? '完成补单' : '完成'}}</button>
<button class="danger-btn" bindtap="cancel">取消</button>
</view>
</view>
+16 -3
View File
@@ -85,6 +85,7 @@ Page({
freeArtistCount: 0,
pendingCount: 0,
unassignedCount: 0,
historicalBackfillItems: [],
rangeUnassignedCount: 0,
nearestUnassignedDate: '',
canCreateAppointment: true,
@@ -481,9 +482,11 @@ Page({
? (calendar.artists || []).filter(item => String(item.id) === String(this.data.selectedArtistId))
: (calendar.artists || [])
const dayAppointments = (calendar.appointments || []).filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
const historicalBackfillItems = dayAppointments.filter(item => item.historicalBackfill)
const employeeLanes = filteredArtists.map(artist => {
const blocks = dayAppointments
.filter(item => String(item.artistId) === String(artist.id))
.filter(item => item.startTime)
.map(item => {
const itemStart = resolveAppointmentStartMinute(item)
return {
@@ -497,6 +500,7 @@ Page({
})
const unassignedBlocks = dayAppointments
.filter(item => !item.artistId)
.filter(item => item.startTime)
.map(item => {
const itemStart = resolveAppointmentStartMinute(item)
return {
@@ -523,9 +527,10 @@ Page({
laneItemWidth: 248,
laneWidth: Math.max(720, lanes.length * 248),
dayTotal: dayAppointments.length,
freeArtistCount: employeeLanes.filter(item => item.blocks.length === 0).length,
freeArtistCount: employeeLanes.filter(item => item.blocks.every(block => block.historicalBackfill)).length,
pendingCount,
unassignedCount: unassignedBlocks.length
unassignedCount: unassignedBlocks.length,
historicalBackfillItems
}
},
@@ -625,6 +630,14 @@ Page({
this.openAppointmentForm(this.data.currentDateText)
},
openBackfillOrder() {
if (!this.data.canCreateAppointment) {
wx.showToast({ title: '当前账号仅支持查看预约', icon: 'none' })
return
}
wx.navigateTo({ url: '/pages/backfill-order/index' })
},
openAppointmentForm(appointmentDate) {
const query = [`date=${encodeURIComponent(appointmentDate)}`]
if (this.data.selectedArtistId) {
@@ -647,7 +660,7 @@ Page({
if (!appointment) return
try {
await planningApi.updateStatus(appointment.orderId, Number(event.currentTarget.dataset.status))
wx.showToast({ title: '预约已确认', icon: 'success' })
wx.showToast({ title: Number(event.currentTarget.dataset.status) === 2 ? '补单已完成' : '预约已确认', icon: 'success' })
this.loadCalendar()
} catch (error) {
wx.showToast({ title: error.message || '预约状态更新失败', icon: 'none' })
+12 -3
View File
@@ -20,6 +20,7 @@
<view class="segmented">
<view wx:for="{{viewModes}}" wx:key="value" class="segment {{viewMode === item.value ? 'active' : ''}}" data-mode="{{item.value}}" bindtap="switchView">{{item.label}}</view>
</view>
<button wx:if="{{canCreateAppointment}}" class="backfill-entry" bindtap="openBackfillOrder">补录历史订单</button>
<scroll-view class="artist-filter" scroll-x enable-flex>
<view class="artist-chip {{!selectedArtistId ? 'active' : ''}}" data-id="" bindtap="selectArtist">全部员工</view>
<view wx:for="{{artists}}" wx:key="id" class="artist-chip {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
@@ -57,6 +58,13 @@
<block wx:if="{{!calendarError}}">
<view wx:if="{{viewMode === 'day'}}" class="section">
<view wx:if="{{historicalBackfillItems.length}}" class="card historical-backfill-card">
<view class="section-title">历史补单</view>
<view wx:for="{{historicalBackfillItems}}" wx:key="orderItemId" class="historical-backfill-row" data-id="{{item.orderItemId}}" bindtap="openAppointment">
<view><text>{{item.customerName || '散客'}} · {{item.productTitle}}</text><text class="muted">{{item.artistName}} · {{item.startTime || '时间未记录'}}</text></view>
<text>{{item.statusText}} · ¥{{item.amount}}</text>
</view>
</view>
<view class="day-summary">
<view class="summary-item card">
<text class="summary-value">{{dayTotal}}</text>
@@ -93,9 +101,10 @@
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
<text class="block-status">{{block.statusText}}</text>
<view class="block-actions" catchtap="stopTap">
<text wx:if="{{block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
<text data-id="{{block.orderItemId}}" catchtap="quickTransfer">{{block.assignmentStatus === 'UNASSIGNED' ? '分配' : '改派'}}</text>
<text data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
<text wx:if="{{!block.historicalBackfill && block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
<text wx:if="{{!block.historicalBackfill}}" data-id="{{block.orderItemId}}" catchtap="quickTransfer">{{block.assignmentStatus === 'UNASSIGNED' ? '分配' : '改派'}}</text>
<text wx:if="{{!block.historicalBackfill || block.status === 4}}" data-id="{{block.orderItemId}}" catchtap="quickCancel">取消</text>
<text wx:if="{{block.historicalBackfill && block.status === 4}}" data-id="{{block.orderItemId}}" data-status="2" catchtap="quickUpdateStatus">完成</text>
</view>
</view>
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
@@ -769,3 +769,6 @@
transform: translateY(0);
}
}
.backfill-entry{margin:18rpx 0 0;background:#f1ebe4;color:#4f766d;border:1rpx solid #d9cfc3;font-size:25rpx;line-height:68rpx;height:68rpx;border-radius:12rpx}
.historical-backfill-card{margin:20rpx 0;padding:22rpx}.historical-backfill-row{display:flex;justify-content:space-between;align-items:center;padding:18rpx 0;border-top:1rpx solid #eee7df;font-size:26rpx}.historical-backfill-row .muted{display:block;color:#92887e;font-size:22rpx;margin-top:8rpx}
@@ -0,0 +1,43 @@
-- 历史补单与服务中状态(可重复执行)
-- 不执行数据迁移,仅为新部署环境补充字段。
SET @db_name = DATABASE();
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order MODIFY COLUMN user_id BIGINT UNSIGNED NULL COMMENT ''客户用户ID,补单可为空''',
'SELECT 1') FROM information_schema.columns
WHERE table_schema = @db_name AND table_name = 't_order' AND column_name = 'user_id' AND is_nullable = 'YES');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order ADD COLUMN customer_name_snapshot VARCHAR(100) NULL COMMENT ''补单客户名称快照'' AFTER customer_remark',
'SELECT 1') FROM information_schema.columns WHERE table_schema = @db_name AND table_name = 't_order' AND column_name = 'customer_name_snapshot');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order ADD COLUMN customer_phone_snapshot VARCHAR(32) NULL COMMENT ''补单客户手机号快照'' AFTER customer_name_snapshot',
'SELECT 1') FROM information_schema.columns WHERE table_schema = @db_name AND table_name = 't_order' AND column_name = 'customer_phone_snapshot');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order ADD COLUMN order_source VARCHAR(32) NOT NULL DEFAULT ''NORMAL_APPOINTMENT'' COMMENT ''订单来源'' AFTER customer_remark',
'SELECT 1') FROM information_schema.columns
WHERE table_schema = @db_name AND table_name = 't_order' AND column_name = 'order_source');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order_item ADD COLUMN service_date DATE NULL COMMENT ''业务服务日期,历史补单无具体时间时使用'' AFTER appointment_time',
'SELECT 1') FROM information_schema.columns
WHERE table_schema = @db_name AND table_name = 't_order_item' AND column_name = 'service_date');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order ADD INDEX idx_order_source_status_delete (order_source, status, is_delete)',
'SELECT 1') FROM information_schema.statistics
WHERE table_schema = @db_name AND table_name = 't_order' AND index_name = 'idx_order_source_status_delete');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
SET @sql = (SELECT IF(COUNT(*) = 0,
'ALTER TABLE t_order_item ADD INDEX idx_order_item_artist_service_date (artist_id, service_date, is_delete)',
'SELECT 1') FROM information_schema.statistics
WHERE table_schema = @db_name AND table_name = 't_order_item' AND index_name = 'idx_order_item_artist_service_date');
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
@@ -0,0 +1,5 @@
# 历史补单与服务中状态
历史补单使用订单来源 `HISTORICAL_BACKFILL`,状态 `4` 表示服务中。补单必须归属员工,可不填写客户和具体服务时间;没有具体时间时仅按 `service_date` 参与规划日期统计,不创建预约占用,也不执行排班冲突校验。
数据库字段由 `docs/scripts/sql/versions/历史补单与服务中状态_20261013.sql` 增补。该脚本只修改字段和索引,不连接或清理已有业务数据。
@@ -0,0 +1,17 @@
# Salon 历史补单与服务中状态设计
## 目标
通过独立补单入口记录已经发生或正在服务中的业务,不改变普通预约的历史日期限制、排班校验和预约占用逻辑。
## 状态与数据
订单新增 `IN_SERVICE(4)`,仅 `HISTORICAL_BACKFILL` 来源允许创建为该状态。补单必须有项目、金额、服务日期和员工;客户、手机号、具体服务时间和备注可为空。服务日期写入订单项 `service_date`,具体时间存在时才写入 `appointment_time`。
## 展示与流转
规划页提供独立“补录历史订单”入口。没有具体时间的补单显示在日视图“历史补单”区域,不进入时间轴;有时间的记录可展示但不产生排班容量占用。服务中补单可完成或取消,已完成补单不再进入普通预约流程。
## 兼容与验证
普通预约接口和状态流转保持原规则。数据库字段通过 `docs/scripts/sql/versions/历史补单与服务中状态_20261013.sql` 增补,不修改冻结初始化 SQL;后端编译通过,客户端脚本执行语法检查。
+6
View File
@@ -179,3 +179,9 @@
- 本次现有字段已支持员工为空,未修改冻结初始化 SQL、版本 SQL、Nacos、后台管理或 ArtList。
- GitNexus 已执行关键符号影响分析,但当前索引无法识别相关 Java/小程序页面方法并返回 `UNKNOWN`;本次以静态调用链、Core 测试与编译、小程序全量状态测试替代验证。
## 2026-10-13 历史补单与服务中状态
- 新增历史补单接口与小程序独立补单页面,补单可直接进入“服务中”或“已完成”。
- 新增 `IN_SERVICE(4)` 状态、历史补单来源和服务日期字段;无具体时间的补单仅参与日期统计,不创建预约占用。
- 规划页增加补录入口、历史补单展示,后台订单筛选增加服务中状态。
- 数据库字段与索引变更见 `docs/scripts/sql/versions/历史补单与服务中状态_20261013.sql`。