修复预约改派与员工统计展示
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,
|
||||
|
||||
Reference in New Issue
Block a user