修复预约改派与员工统计展示
This commit is contained in:
+25
@@ -134,4 +134,29 @@ public class NailArtistInfoDTO {
|
||||
* 排班时间摘要
|
||||
*/
|
||||
private String scheduleTimeSummary;
|
||||
|
||||
/**
|
||||
* 本月订单数
|
||||
*/
|
||||
private Long monthOrders;
|
||||
|
||||
/**
|
||||
* 本月营业额
|
||||
*/
|
||||
private BigDecimal monthAmount;
|
||||
|
||||
/**
|
||||
* 平均客单价
|
||||
*/
|
||||
private BigDecimal avgAmount;
|
||||
|
||||
/**
|
||||
* 当前状态码
|
||||
*/
|
||||
private String currentStatusCode;
|
||||
|
||||
/**
|
||||
* 当前状态文案
|
||||
*/
|
||||
private String currentStatusText;
|
||||
}
|
||||
|
||||
+107
-3
@@ -9,6 +9,7 @@ import com.xiaowang.jayucloud.core.modules.artist.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleExceptionDO;
|
||||
import com.xiaowang.jayucloud.core.modules.product.entity.ProductDO;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
|
||||
@@ -16,6 +17,7 @@ import com.xiaowang.jayucloud.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleRuleMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleExceptionMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderMapper;
|
||||
@@ -116,6 +118,9 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleRuleMapper artistScheduleRuleMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ArtistScheduleExceptionMapper artistScheduleExceptionMapper;
|
||||
|
||||
@Autowired(required = false)
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
@@ -132,11 +137,15 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
.eq(NailArtistInfoDO::getIsDelete, 0)
|
||||
.last("LIMIT 1"));
|
||||
if (info != null) {
|
||||
return convertToDTO(info);
|
||||
NailArtistInfoDTO dto = convertToDTO(info);
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
return dto;
|
||||
}
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
if (user != null && Integer.valueOf(2).equals(user.getType())) {
|
||||
return buildManagerFallbackArtistInfo(user);
|
||||
NailArtistInfoDTO dto = buildManagerFallbackArtistInfo(user);
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
return dto;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -158,6 +167,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
}
|
||||
}
|
||||
enrichScheduleSummaries(result, null);
|
||||
enrichCurrentStatusAndMonthlyStats(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -187,9 +197,11 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
NailArtistInfoDTO dto = getByUserId(user.getId());
|
||||
if (dto == null) {
|
||||
dto = buildFallbackArtistInfo(user);
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
}
|
||||
dto.setShopId(shopId);
|
||||
dto.setShopName(shop == null ? null : shop.getShopName());
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
result.add(dto);
|
||||
}
|
||||
enrichScheduleSummaries(result, shopId);
|
||||
@@ -209,7 +221,6 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
List<UserDO> users = userMapper.selectList(new LambdaQueryWrapper<UserDO>()
|
||||
.in(UserDO::getId, candidateUserIds)
|
||||
.in(UserDO::getType, List.of(2, 3))
|
||||
.eq(UserDO::getStatus, 1)
|
||||
.eq(UserDO::getIsDelete, 0)
|
||||
.orderByAsc(UserDO::getCreateTime)
|
||||
.orderByAsc(UserDO::getId));
|
||||
@@ -224,9 +235,11 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
dto = Integer.valueOf(2).equals(user.getType())
|
||||
? buildManagerFallbackArtistInfo(user)
|
||||
: buildFallbackArtistInfo(user);
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
}
|
||||
dto.setShopId(shopId);
|
||||
dto.setShopName(shop == null ? null : shop.getShopName());
|
||||
enrichCurrentStatusAndMonthlyStats(dto);
|
||||
result.add(dto);
|
||||
}
|
||||
enrichScheduleSummaries(result, shopId);
|
||||
@@ -630,6 +643,97 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
return StringUtils.hasText(accessibleUrl) ? accessibleUrl : avatar;
|
||||
}
|
||||
|
||||
private void enrichCurrentStatusAndMonthlyStats(List<NailArtistInfoDTO> artists) {
|
||||
if (artists == null || artists.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
artists.forEach(this::enrichCurrentStatusAndMonthlyStats);
|
||||
}
|
||||
|
||||
private void enrichCurrentStatusAndMonthlyStats(NailArtistInfoDTO artist) {
|
||||
if (artist == null || artist.getUserId() == null || artist.getUserId() <= 0) {
|
||||
return;
|
||||
}
|
||||
applyMonthlyStats(artist);
|
||||
applyCurrentStatus(artist);
|
||||
}
|
||||
|
||||
private void applyMonthlyStats(NailArtistInfoDTO artist) {
|
||||
if (artist.getShopId() == null || artist.getShopId() <= 0) {
|
||||
artist.setMonthOrders(0L);
|
||||
artist.setMonthAmount(BigDecimal.ZERO);
|
||||
artist.setAvgAmount(BigDecimal.ZERO);
|
||||
return;
|
||||
}
|
||||
LocalDate today = LocalDate.now();
|
||||
LocalDateTime monthStart = today.withDayOfMonth(1).atStartOfDay();
|
||||
LocalDateTime nextMonthStart = today.plusMonths(1).withDayOfMonth(1).atStartOfDay();
|
||||
List<OrderItemDO> items = orderItemMapper.selectMonthlyItemsByArtistAndShop(
|
||||
artist.getUserId(),
|
||||
artist.getShopId(),
|
||||
monthStart,
|
||||
nextMonthStart
|
||||
);
|
||||
long monthOrders = items == null ? 0L : items.stream()
|
||||
.filter(item -> item != null && !isDeleted(item.getIsDelete()))
|
||||
.count();
|
||||
BigDecimal monthAmount = items == null ? BigDecimal.ZERO : items.stream()
|
||||
.filter(item -> item != null && !isDeleted(item.getIsDelete()))
|
||||
.map(this::resolveOrderItemAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
artist.setMonthOrders(monthOrders);
|
||||
artist.setMonthAmount(monthAmount);
|
||||
artist.setAvgAmount(monthOrders <= 0
|
||||
? BigDecimal.ZERO
|
||||
: monthAmount.divide(BigDecimal.valueOf(monthOrders), 2, RoundingMode.HALF_UP));
|
||||
}
|
||||
|
||||
private BigDecimal resolveOrderItemAmount(OrderItemDO item) {
|
||||
BigDecimal unitPrice = item.getConfirmedPrice();
|
||||
if (unitPrice == null) {
|
||||
unitPrice = item.getQuotedPrice();
|
||||
}
|
||||
if (unitPrice == null) {
|
||||
unitPrice = item.getPrice();
|
||||
}
|
||||
if (unitPrice == null) {
|
||||
unitPrice = BigDecimal.ZERO;
|
||||
}
|
||||
int quantity = item.getQuantity() == null || item.getQuantity() <= 0 ? 1 : item.getQuantity();
|
||||
return unitPrice.multiply(BigDecimal.valueOf(quantity));
|
||||
}
|
||||
|
||||
private void applyCurrentStatus(NailArtistInfoDTO artist) {
|
||||
UserDO user = artist.getUserId() == null ? null : userMapper.selectById(artist.getUserId());
|
||||
if (user == null || !Integer.valueOf(1).equals(user.getStatus()) || !Integer.valueOf(1).equals(artist.getStatus())) {
|
||||
artist.setCurrentStatusCode("DISABLED");
|
||||
artist.setCurrentStatusText("停用");
|
||||
return;
|
||||
}
|
||||
if (isArtistRestingToday(artist)) {
|
||||
artist.setCurrentStatusCode("REST");
|
||||
artist.setCurrentStatusText("休假");
|
||||
return;
|
||||
}
|
||||
artist.setCurrentStatusCode("NORMAL");
|
||||
artist.setCurrentStatusText("正常");
|
||||
}
|
||||
|
||||
private boolean isArtistRestingToday(NailArtistInfoDTO artist) {
|
||||
if (artistScheduleExceptionMapper == null || artist.getUserId() == null || artist.getShopId() == null) {
|
||||
return false;
|
||||
}
|
||||
LocalDate today = LocalDate.now();
|
||||
ArtistScheduleExceptionDO exception = artistScheduleExceptionMapper.selectOne(new LambdaQueryWrapper<ArtistScheduleExceptionDO>()
|
||||
.eq(ArtistScheduleExceptionDO::getArtistId, artist.getUserId())
|
||||
.eq(ArtistScheduleExceptionDO::getShopId, artist.getShopId())
|
||||
.eq(ArtistScheduleExceptionDO::getWorkDate, today)
|
||||
.eq(ArtistScheduleExceptionDO::getExceptionType, "REST")
|
||||
.eq(ArtistScheduleExceptionDO::getIsDelete, 0)
|
||||
.last("LIMIT 1"));
|
||||
return exception != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `isVisibleServiceUser`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
|
||||
+14
@@ -42,6 +42,20 @@ public interface OrderItemMapper extends BaseMapper<OrderItemDO> {
|
||||
List<OrderItemDO> selectArtistCalendarItems(@Param("artistId") Long artistId,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT oi.* FROM t_order_item oi " +
|
||||
"INNER JOIN t_order o ON o.id = oi.order_id " +
|
||||
"WHERE oi.artist_id = #{artistId} " +
|
||||
"AND o.shop_id = #{shopId} " +
|
||||
"AND oi.is_delete = 0 " +
|
||||
"AND o.is_delete = 0 " +
|
||||
"AND o.status <> 3 " +
|
||||
"AND oi.appointment_time >= #{startTime} " +
|
||||
"AND oi.appointment_time < #{endTime}")
|
||||
List<OrderItemDO> selectMonthlyItemsByArtistAndShop(@Param("artistId") Long artistId,
|
||||
@Param("shopId") Long shopId,
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
@Select("SELECT COUNT(DISTINCT oi.order_id) as count FROM t_order_item oi " +
|
||||
"JOIN t_product p ON oi.product_id = p.id " +
|
||||
|
||||
+98
-1
@@ -19,6 +19,7 @@ import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderArtistChangeRequestDO;
|
||||
import com.xiaowang.jayucloud.core.modules.product.entity.ProductDO;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.entity.ShopScheduleExceptionDO;
|
||||
@@ -30,6 +31,7 @@ import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleRuleMappe
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderArtistChangeRequestMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.shop.mapper.ShopScheduleExceptionMapper;
|
||||
@@ -50,6 +52,7 @@ import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningArtistVO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningCalendarVO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningDaySummaryVO;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.vo.PlanningScheduleVO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.vo.OrderArtistChangeRequestVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -101,6 +104,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private final AppointmentReservationMapper appointmentReservationMapper;
|
||||
private final OrderMapper orderMapper;
|
||||
private final OrderItemMapper orderItemMapper;
|
||||
private final OrderArtistChangeRequestMapper orderArtistChangeRequestMapper;
|
||||
private final ProductMapper productMapper;
|
||||
private final ObjectStorageFileService objectStorageFileService;
|
||||
private final ObjectStorageUrlSupport objectStorageUrlSupport;
|
||||
@@ -245,7 +249,16 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
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()));
|
||||
return toAppointmentVO(reservation, item, order, product, customerMap.get(order.getUserId()), artistMap);
|
||||
PlanningAppointmentVO appointment = toAppointmentVO(
|
||||
reservation,
|
||||
item,
|
||||
order,
|
||||
product,
|
||||
customerMap.get(order.getUserId()),
|
||||
artistMap
|
||||
);
|
||||
appointment.setArtistChangeRequests(loadArtistChangeRequests(order.getId()));
|
||||
return appointment;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,9 +366,13 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
endTime
|
||||
);
|
||||
|
||||
Long previousArtistId = item.getArtistId();
|
||||
item.setArtistId(artist.getId());
|
||||
item.setAppointmentTime(startTime);
|
||||
orderItemMapper.updateById(item);
|
||||
if (!Objects.equals(previousArtistId, artist.getId())) {
|
||||
saveDirectArtistChangeRequest(currentUser, order, item, previousArtistId, artist.getId());
|
||||
}
|
||||
return getAppointment(currentUser, item.getId());
|
||||
}
|
||||
|
||||
@@ -442,6 +459,86 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
return amount;
|
||||
}
|
||||
|
||||
private void saveDirectArtistChangeRequest(UserDO currentUser, OrderDO order, OrderItemDO item,
|
||||
Long fromArtistId, Long toArtistId) {
|
||||
OrderArtistChangeRequestDO request = new OrderArtistChangeRequestDO();
|
||||
request.setOrderId(order.getId());
|
||||
request.setOrderItemId(item.getId());
|
||||
request.setProductId(item.getProductId());
|
||||
request.setShopId(order.getShopId());
|
||||
request.setCustomerId(order.getUserId());
|
||||
request.setFromArtistId(fromArtistId);
|
||||
request.setToArtistId(toArtistId);
|
||||
request.setRequesterId(currentUser.getId());
|
||||
request.setStatus("APPROVED");
|
||||
request.setReason("店务直接改派");
|
||||
request.setApprovedTime(LocalDateTime.now());
|
||||
request.setIsDelete(0);
|
||||
orderArtistChangeRequestMapper.insert(request);
|
||||
}
|
||||
|
||||
private List<OrderArtistChangeRequestVO> loadArtistChangeRequests(Long orderId) {
|
||||
List<OrderArtistChangeRequestDO> requests = orderArtistChangeRequestMapper.selectByOrderId(orderId);
|
||||
if (requests == null || requests.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return requests.stream()
|
||||
.map(this::toArtistChangeRequestVO)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private OrderArtistChangeRequestVO toArtistChangeRequestVO(OrderArtistChangeRequestDO request) {
|
||||
OrderArtistChangeRequestVO vo = new OrderArtistChangeRequestVO();
|
||||
vo.setId(request.getId());
|
||||
vo.setOrderId(request.getOrderId());
|
||||
vo.setOrderItemId(request.getOrderItemId());
|
||||
vo.setProductId(request.getProductId());
|
||||
vo.setShopId(request.getShopId());
|
||||
vo.setCustomerId(request.getCustomerId());
|
||||
vo.setUserId(request.getCustomerId());
|
||||
vo.setOriginalArtistId(request.getFromArtistId());
|
||||
vo.setFromArtistId(request.getFromArtistId());
|
||||
vo.setRequestedArtistId(request.getToArtistId());
|
||||
vo.setToArtistId(request.getToArtistId());
|
||||
vo.setRequesterId(request.getRequesterId());
|
||||
vo.setStatus(request.getStatus());
|
||||
vo.setStatusText(resolveArtistChangeStatusText(request.getStatus()));
|
||||
vo.setReason(request.getReason());
|
||||
vo.setRejectReason(request.getRejectReason());
|
||||
vo.setApprovedTime(request.getApprovedTime());
|
||||
vo.setRejectedTime(request.getRejectedTime());
|
||||
vo.setExpireTime(request.getExpireTime());
|
||||
vo.setCreateTime(request.getCreateTime());
|
||||
vo.setReviewTime(request.getApprovedTime() != null ? request.getApprovedTime() : request.getRejectedTime());
|
||||
vo.setOriginalArtistName(resolveUserName(request.getFromArtistId()));
|
||||
vo.setFromArtistName(vo.getOriginalArtistName());
|
||||
vo.setRequestedArtistName(resolveUserName(request.getToArtistId()));
|
||||
vo.setToArtistName(vo.getRequestedArtistName());
|
||||
vo.setRequesterName(resolveUserName(request.getRequesterId()));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private String resolveUserName(Long userId) {
|
||||
if (userId == null) {
|
||||
return null;
|
||||
}
|
||||
UserDO user = userMapper.selectById(userId);
|
||||
return user == null ? null : user.getNickname();
|
||||
}
|
||||
|
||||
private String resolveArtistChangeStatusText(String status) {
|
||||
if ("APPROVED".equals(status)) {
|
||||
return "已改派";
|
||||
}
|
||||
if ("REJECTED".equals(status)) {
|
||||
return "已拒绝";
|
||||
}
|
||||
if ("EXPIRED".equals(status)) {
|
||||
return "已过期";
|
||||
}
|
||||
return "待处理";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Boolean updateStatus(UserDO currentUser, Long orderId, PlanningAppointmentStatusDTO dto) {
|
||||
|
||||
+2
@@ -1,5 +1,6 @@
|
||||
package com.xiaowang.jayucloud.core.modules.planning.vo;
|
||||
|
||||
import com.xiaowang.jayucloud.core.modules.order.vo.OrderArtistChangeRequestVO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -40,4 +41,5 @@ public class PlanningAppointmentVO {
|
||||
private String productPrecautions;
|
||||
private String productImageFileIds;
|
||||
private List<String> productImageUrls = new ArrayList<>();
|
||||
private List<OrderArtistChangeRequestVO> artistChangeRequests = new ArrayList<>();
|
||||
}
|
||||
|
||||
+65
@@ -2,6 +2,7 @@ package com.xiaowang.jayucloud.core.modules.artist.service.impl;
|
||||
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleExceptionDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.dto.NailArtistInfoDTO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderArtistReviewDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
|
||||
@@ -12,6 +13,7 @@ import com.xiaowang.jayucloud.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleExceptionMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderArtistReviewMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderMapper;
|
||||
@@ -73,6 +75,8 @@ class NailArtistInfoServiceImplTest {
|
||||
@Mock
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
@Mock
|
||||
private ArtistScheduleExceptionMapper artistScheduleExceptionMapper;
|
||||
@Mock
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
private NailArtistInfoServiceImpl service;
|
||||
@@ -92,6 +96,7 @@ class NailArtistInfoServiceImplTest {
|
||||
ReflectionTestUtils.setField(service, "objectStorageFileService", objectStorageFileService);
|
||||
ReflectionTestUtils.setField(service, "objectStorageUrlSupport", objectStorageUrlSupport);
|
||||
ReflectionTestUtils.setField(service, "artistScheduleMapper", artistScheduleMapper);
|
||||
ReflectionTestUtils.setField(service, "artistScheduleExceptionMapper", artistScheduleExceptionMapper);
|
||||
ReflectionTestUtils.setField(service, "appointmentReservationMapper", appointmentReservationMapper);
|
||||
when(userShopBindingSupport.listShopOptionsByUserId(any(), anyBoolean(), anyBoolean())).thenReturn(List.of());
|
||||
when(objectStorageUrlSupport.toAccessibleUrl(any(String.class)))
|
||||
@@ -209,6 +214,66 @@ class NailArtistInfoServiceImplTest {
|
||||
.doesNotContain(8L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getByUserIdReturnsMonthlyStatsAndDisabledStatusFirst() {
|
||||
NailArtistInfoDO artistInfo = new NailArtistInfoDO();
|
||||
artistInfo.setId(11L);
|
||||
artistInfo.setUserId(7L);
|
||||
artistInfo.setIdentity("高级美甲师");
|
||||
artistInfo.setStatus(1);
|
||||
artistInfo.setIsDelete(0);
|
||||
when(nailArtistInfoMapper.selectOne(any())).thenReturn(artistInfo);
|
||||
|
||||
UserDO user = new UserDO();
|
||||
user.setId(7L);
|
||||
user.setNickname("Mina");
|
||||
user.setAvatar("https://img.test/mina.jpg");
|
||||
user.setPhone("13800138000");
|
||||
user.setContactPhone("13900139000");
|
||||
user.setWechatId("wx_mina");
|
||||
user.setType(3);
|
||||
user.setShopId(9L);
|
||||
user.setStatus(0);
|
||||
user.setIsDelete(0);
|
||||
when(userMapper.selectById(7L)).thenReturn(user);
|
||||
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setId(9L);
|
||||
shop.setShopName("测试门店");
|
||||
when(shopMapper.selectById(9L)).thenReturn(shop);
|
||||
|
||||
OrderItemDO firstItem = new OrderItemDO();
|
||||
firstItem.setId(21L);
|
||||
firstItem.setArtistId(7L);
|
||||
firstItem.setQuantity(1);
|
||||
firstItem.setConfirmedPrice(new BigDecimal("100.00"));
|
||||
firstItem.setIsDelete(0);
|
||||
OrderItemDO secondItem = new OrderItemDO();
|
||||
secondItem.setId(22L);
|
||||
secondItem.setArtistId(7L);
|
||||
secondItem.setQuantity(2);
|
||||
secondItem.setPrice(new BigDecimal("50.00"));
|
||||
secondItem.setIsDelete(0);
|
||||
when(orderItemMapper.selectMonthlyItemsByArtistAndShop(any(), any(), any(), any()))
|
||||
.thenReturn(List.of(firstItem, secondItem));
|
||||
|
||||
ArtistScheduleExceptionDO exception = new ArtistScheduleExceptionDO();
|
||||
exception.setArtistId(7L);
|
||||
exception.setShopId(9L);
|
||||
exception.setWorkDate(LocalDate.now());
|
||||
exception.setExceptionType("REST");
|
||||
exception.setIsDelete(0);
|
||||
when(artistScheduleExceptionMapper.selectOne(any())).thenReturn(exception);
|
||||
|
||||
NailArtistInfoDTO dto = service.getByUserId(7L);
|
||||
|
||||
assertThat(dto.getMonthOrders()).isEqualTo(2L);
|
||||
assertThat(dto.getMonthAmount()).isEqualByComparingTo("200.00");
|
||||
assertThat(dto.getAvgAmount()).isEqualByComparingTo("100.00");
|
||||
assertThat(dto.getCurrentStatusCode()).isEqualTo("DISABLED");
|
||||
assertThat(dto.getCurrentStatusText()).isEqualTo("停用");
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveOrUpdateNailArtistInfoSyncsNicknameToUser() {
|
||||
NailArtistInfoDO existing = new NailArtistInfoDO();
|
||||
|
||||
+6
@@ -11,7 +11,9 @@ import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.entity.OrderArtistChangeRequestDO;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.order.mapper.OrderArtistChangeRequestMapper;
|
||||
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;
|
||||
@@ -82,6 +84,9 @@ class PlanningServiceImplTest {
|
||||
@Mock
|
||||
private OrderItemMapper orderItemMapper;
|
||||
|
||||
@Mock
|
||||
private OrderArtistChangeRequestMapper orderArtistChangeRequestMapper;
|
||||
|
||||
@Mock
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@@ -123,6 +128,7 @@ class PlanningServiceImplTest {
|
||||
appointmentReservationMapper,
|
||||
orderMapper,
|
||||
orderItemMapper,
|
||||
orderArtistChangeRequestMapper,
|
||||
productMapper,
|
||||
objectStorageFileService,
|
||||
objectStorageUrlSupport,
|
||||
|
||||
@@ -208,6 +208,7 @@ Page({
|
||||
timeText: '',
|
||||
priceText: '未定',
|
||||
detailTags: [],
|
||||
artistChangeRequests: [],
|
||||
productImageUrls: [],
|
||||
productImageFileIds: '',
|
||||
imageUploading: false,
|
||||
@@ -244,6 +245,7 @@ Page({
|
||||
timeText: '',
|
||||
priceText: '未定',
|
||||
detailTags: [],
|
||||
artistChangeRequests: [],
|
||||
productImageUrls: [],
|
||||
productImageFileIds: '',
|
||||
canEditAppointment: false,
|
||||
@@ -263,17 +265,22 @@ Page({
|
||||
const status = Number(appointment.status)
|
||||
const showPendingActions = status === STATUS_PENDING_SERVICE
|
||||
const showRestoreAction = status === STATUS_COMPLETED || status === STATUS_CANCELLED
|
||||
const canEditAppointment = Boolean(appointment.canEdit)
|
||||
const canTransfer = canTransferAppointment() && canEditAppointment
|
||||
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),
|
||||
artistChangeRequests: Array.isArray(appointment.artistChangeRequests)
|
||||
? appointment.artistChangeRequests
|
||||
: [],
|
||||
productImageUrls: imageUrls,
|
||||
productImageFileIds: resolveProductImageFileIds(appointment).join(','),
|
||||
canEditAppointment: Boolean(appointment.canEdit),
|
||||
canTransferAppointment: canTransferAppointment(),
|
||||
showActionRow: showPendingActions || showRestoreAction,
|
||||
canEditAppointment,
|
||||
canTransferAppointment: canTransfer,
|
||||
showActionRow: showPendingActions || showRestoreAction || canTransfer,
|
||||
showPendingActions,
|
||||
showRestoreAction,
|
||||
loadError: ''
|
||||
@@ -328,7 +335,7 @@ Page({
|
||||
},
|
||||
|
||||
goTransfer() {
|
||||
if (!this.data.canTransferAppointment) {
|
||||
if (!this.data.canTransferAppointment || !this.data.canEditAppointment) {
|
||||
wx.showToast({ title: '只有店长可以改派预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
@@ -73,6 +73,23 @@
|
||||
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError && artistChangeRequests.length}}" class="section">
|
||||
<view class="section-title">改派历史</view>
|
||||
<view class="card change-history-card">
|
||||
<view wx:for="{{artistChangeRequests}}" wx:key="id" class="change-history-item">
|
||||
<view class="change-history-path">
|
||||
<text>{{item.fromArtistName || '未分配'}}</text>
|
||||
<text class="change-history-arrow">→</text>
|
||||
<text>{{item.toArtistName || '未分配'}}</text>
|
||||
</view>
|
||||
<view class="change-history-meta">
|
||||
<text>操作人:{{item.requesterName || '系统'}}</text>
|
||||
<text>{{item.approvedTime || item.createTime || ''}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{priceModalVisible}}" class="detail-modal-mask" catchtap="stopTap">
|
||||
<view class="price-modal" catchtap="stopTap">
|
||||
<view class="price-modal-head">
|
||||
@@ -97,9 +114,10 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!loadError && showActionRow}}" class="fixed-bottom action-row {{showRestoreAction ? 'single' : ''}}">
|
||||
<view wx:if="{{!loadError && showActionRow}}" class="fixed-bottom action-row {{showRestoreAction ? 'single' : ''}} {{canTransferAppointment ? 'with-transfer' : ''}}">
|
||||
<button wx:if="{{showPendingActions}}" class="primary-btn" bindtap="complete">完成</button>
|
||||
<button wx:if="{{showPendingActions}}" class="danger-btn" bindtap="deleteAppointment">删除此订单</button>
|
||||
<button wx:if="{{canTransferAppointment}}" class="secondary-btn transfer-btn" bindtap="goTransfer">改派</button>
|
||||
<button wx:if="{{showRestoreAction}}" class="secondary-btn" bindtap="restorePending">修改状态</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -165,6 +165,42 @@
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-history-card {
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
|
||||
.change-history-item {
|
||||
padding: 22rpx 0;
|
||||
border-bottom: 1rpx solid #eee5dc;
|
||||
}
|
||||
|
||||
.change-history-item:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.change-history-path {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
color: #2d2924;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.change-history-arrow {
|
||||
color: #7d9d90;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.change-history-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
margin-top: 10rpx;
|
||||
color: #9a9288;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -392,6 +428,10 @@
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.action-row.with-transfer {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.action-row .primary-btn,
|
||||
.action-row .secondary-btn,
|
||||
.action-row .danger-btn {
|
||||
|
||||
@@ -1016,7 +1016,7 @@
|
||||
|
||||
.manual-field-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 248rpx;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
@@ -1176,13 +1176,15 @@
|
||||
|
||||
.manual-tag-input-row {
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 140rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 12rpx;
|
||||
margin-top: 12rpx;
|
||||
}
|
||||
|
||||
.manual-tag-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
height: 70rpx;
|
||||
padding: 0 18rpx;
|
||||
@@ -1195,9 +1197,10 @@
|
||||
|
||||
.manual-tag-add {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
flex: 0 0 140rpx;
|
||||
width: 140rpx;
|
||||
min-width: 140rpx;
|
||||
max-width: 140rpx;
|
||||
}
|
||||
|
||||
.manual-image-row {
|
||||
@@ -1315,20 +1318,25 @@
|
||||
}
|
||||
|
||||
.manual-action-row {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
||||
box-sizing: border-box;
|
||||
min-width: 0;
|
||||
gap: 14rpx;
|
||||
margin-top: 18rpx;
|
||||
padding-top: 18rpx;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) + 4rpx);
|
||||
background: linear-gradient(180deg, rgba(247, 239, 231, 0), #f7efe7 26rpx);
|
||||
}
|
||||
|
||||
.manual-action-row .secondary-btn,
|
||||
.manual-action-row .primary-btn {
|
||||
flex: none;
|
||||
width: auto;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.action-row {
|
||||
|
||||
@@ -43,6 +43,9 @@ Page({
|
||||
const name = data.nickname || data.name || data.artistName || '美甲师'
|
||||
const monthOrders = data.monthOrders || data.orderCount || 0
|
||||
const monthAmount = data.monthAmount || data.turnover || 0
|
||||
const avgAmount = data.avgAmount === undefined || data.avgAmount === null
|
||||
? (monthOrders > 0 ? Math.round(monthAmount / monthOrders) : 0)
|
||||
: data.avgAmount
|
||||
this.setData({
|
||||
loadError: '',
|
||||
employee: {
|
||||
@@ -58,7 +61,8 @@ Page({
|
||||
identityText: displayText(data.identity),
|
||||
monthOrders,
|
||||
monthAmount,
|
||||
avgAmount: monthOrders > 0 ? Math.round(monthAmount / monthOrders) : 0
|
||||
avgAmount,
|
||||
currentStatusText: displayText(data.currentStatusText)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
|
||||
@@ -64,6 +64,10 @@
|
||||
<text class="info-label">身份</text>
|
||||
<text class="info-value">{{employee.identityText}}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="info-label">当前状态</text>
|
||||
<text class="info-value">{{employee.currentStatusText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
@@ -577,3 +577,12 @@
|
||||
- Gateway 发布:`192.168.5.253`、`192.168.5.254`、`192.168.10.129` 三台 `jayu-cloud-gateway` 均滚动更新并通过本机健康检查;运行 JAR SHA-256 均为 `b73a2ad1bd44a35031f14a81eb6120f0e7aac794403206eaadcab4abf7436d1b`。
|
||||
- 验证结果:6 台后端服务均为 `active/enabled`;发布后 15 分钟窗口内 Core/Gateway error 级日志数量均为 `0`;`https://yunail.art/health/check` 与 `https://yunail.art/api/shop/list` 均返回 HTTP `200`。
|
||||
- 完成时间:`2026-07-25 12:07:33 +08:00`。
|
||||
|
||||
## 2026-07-25 店务小程序预约与员工管理修复
|
||||
|
||||
- 变更原因:修复新建预约手工作品弹窗窄屏布局、恢复预约详情改派入口,并补充改派轨迹和员工真实统计/当前状态展示。
|
||||
- 处理方式:店务直接改派成功时复用 `t_order_artist_change_request` 写入 `APPROVED` 记录;预约详情返回并展示原美甲师、新美甲师、操作人和时间;员工 DTO 增加本月订单、营业额、平均客单价、当前状态字段;统计按当前自然月、店铺、员工订单项汇总并排除取消订单;状态按停用、休假、正常优先级计算。
|
||||
- 前端范围:`JY-Salon-WeChat/pages/appointment-form/`、`pages/appointment-detail/`、`pages/employee-detail/`。
|
||||
- 后端范围:预约规划服务、员工信息服务、订单项查询 mapper 及对应定向测试。
|
||||
- 数据库说明:本次不新增 SQL,不修改初始化 SQL,不需要执行数据库迁移。
|
||||
- 验证结果:`NailArtistInfoServiceImplTest` 与 `PlanningServiceImplTest` 共 29 个测试通过;店务小程序改动 JS 语法检查通过;改动文件 BOM 检查通过;`git diff --check` 无实质错误。
|
||||
|
||||
Reference in New Issue
Block a user