统一店长参与制作与预约改派规则
This commit is contained in:
+2
-2
@@ -549,7 +549,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
private NailArtistInfoDTO buildManagerFallbackArtistInfo(UserDO user) {
|
||||
NailArtistInfoDTO dto = buildFallbackArtistInfo(user);
|
||||
dto.setIdentity("店长");
|
||||
dto.setParticipateProduction(1);
|
||||
dto.setParticipateProduction(0);
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ public class NailArtistInfoServiceImpl extends ServiceImpl<NailArtistInfoMapper,
|
||||
dto.setUserTypeName(resolveUserTypeName(user.getType()));
|
||||
dto.setIdentity("美甲师");
|
||||
dto.setStatus(1);
|
||||
dto.setParticipateProduction(1);
|
||||
dto.setParticipateProduction(Integer.valueOf(3).equals(user.getType()) ? 1 : 0);
|
||||
dto.setShopId(user.getShopId());
|
||||
List<ShopSimpleVO> shopOptions = userShopBindingSupport.listShopOptionsByUserId(user.getId(), true, true);
|
||||
if (!shopOptions.isEmpty()) {
|
||||
|
||||
+13
-1
@@ -659,6 +659,11 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
for (int i = 0; i < artists.size(); i++) {
|
||||
UserDO user = artists.get(i);
|
||||
NailArtistInfoDO info = infoMap.get(user.getId());
|
||||
if (Integer.valueOf(2).equals(user.getType())
|
||||
&& (artistId == null || !Objects.equals(artistId, user.getId()))
|
||||
&& !isParticipatingManager(info)) {
|
||||
continue;
|
||||
}
|
||||
ArtistScheduleRuleDO rule = ruleMap.get(user.getId());
|
||||
PlanningArtistVO vo = new PlanningArtistVO();
|
||||
vo.setId(user.getId());
|
||||
@@ -1273,12 +1278,19 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
}
|
||||
UserDO artist = userMapper.selectById(artistId);
|
||||
if (artist == null || Integer.valueOf(1).equals(artist.getIsDelete())
|
||||
|| !Integer.valueOf(3).equals(artist.getType()) || !shopId.equals(artist.getShopId())) {
|
||||
|| !shopId.equals(artist.getShopId())
|
||||
|| (!Integer.valueOf(3).equals(artist.getType())
|
||||
&& !(Integer.valueOf(2).equals(artist.getType())
|
||||
&& isParticipatingManager(loadArtistInfo(Set.of(artistId)).get(artistId))))) {
|
||||
throw new RuntimeException("美甲师不存在或不属于当前店铺");
|
||||
}
|
||||
return artist;
|
||||
}
|
||||
|
||||
private boolean isParticipatingManager(NailArtistInfoDO info) {
|
||||
return info != null && Integer.valueOf(1).equals(info.getParticipateProduction());
|
||||
}
|
||||
|
||||
private UserDO resolveCustomer(Long shopId, PlanningAppointmentCreateDTO dto) {
|
||||
if (dto.getCustomerUserId() != null) {
|
||||
UserDO customer = userMapper.selectById(dto.getCustomerUserId());
|
||||
|
||||
+2
-2
@@ -158,7 +158,7 @@ class NailArtistInfoServiceImplTest {
|
||||
assertThat(dto.getNickname()).isEqualTo("门店店长");
|
||||
assertThat(dto.getUserType()).isEqualTo(2);
|
||||
assertThat(dto.getIdentity()).isEqualTo("店长");
|
||||
assertThat(dto.getParticipateProduction()).isOne();
|
||||
assertThat(dto.getParticipateProduction()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,7 +207,7 @@ class NailArtistInfoServiceImplTest {
|
||||
.orElseThrow();
|
||||
assertThat(managerInfo.getUserType()).isEqualTo(2);
|
||||
assertThat(managerInfo.getIdentity()).isEqualTo("店长");
|
||||
assertThat(managerInfo.getParticipateProduction()).isOne();
|
||||
assertThat(managerInfo.getParticipateProduction()).isZero();
|
||||
assertThat(managerInfo.getShopName()).isEqualTo("测试门店");
|
||||
assertThat(result)
|
||||
.extracting(NailArtistInfoDTO::getUserId)
|
||||
|
||||
+28
-1
@@ -6,6 +6,7 @@ import com.xiaowang.jayucloud.core.modules.artist.mapper.ArtistScheduleException
|
||||
import com.xiaowang.jayucloud.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.ArtistScheduleRuleDO;
|
||||
import com.xiaowang.jayucloud.core.modules.artist.entity.NailArtistInfoDO;
|
||||
import com.xiaowang.jayucloud.core.modules.file.service.ObjectStorageFileService;
|
||||
import com.xiaowang.jayucloud.core.modules.file.support.ObjectStorageUrlSupport;
|
||||
import com.xiaowang.jayucloud.core.modules.file.vo.ObjectStorageFileVO;
|
||||
@@ -946,7 +947,10 @@ class PlanningServiceImplTest {
|
||||
when(shopMapper.selectById(8L)).thenReturn(shop);
|
||||
when(shopScheduleExceptionMapper.selectList(any())).thenReturn(List.of());
|
||||
when(userMapper.selectList(any())).thenReturn(List.of(manager));
|
||||
when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of());
|
||||
NailArtistInfoDO managerInfo = new NailArtistInfoDO();
|
||||
managerInfo.setUserId(20L);
|
||||
managerInfo.setParticipateProduction(1);
|
||||
when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of(managerInfo));
|
||||
when(artistScheduleMapper.selectList(any())).thenReturn(List.of());
|
||||
when(artistScheduleRuleMapper.selectList(any()))
|
||||
.thenReturn(List.of(scheduleRule(20L, "EVERYDAY", "1,2,3,4,5,6,7", LocalTime.of(9, 0), LocalTime.of(18, 0))));
|
||||
@@ -962,6 +966,29 @@ class PlanningServiceImplTest {
|
||||
assertThat(calendar.getSchedules().get(0).getArtistId()).isEqualTo(20L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void calendarExcludesManagerWithoutProductionParticipation() {
|
||||
UserDO manager = user(2, 8L);
|
||||
manager.setId(20L);
|
||||
LocalDate date = LocalDate.of(2026, 7, 20);
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setBusinessHours("09:00-18:00");
|
||||
|
||||
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
|
||||
when(shopMapper.selectById(8L)).thenReturn(shop);
|
||||
when(shopScheduleExceptionMapper.selectList(any())).thenReturn(List.of());
|
||||
when(userMapper.selectList(any())).thenReturn(List.of(manager));
|
||||
when(nailArtistInfoMapper.selectList(any())).thenReturn(List.of());
|
||||
when(artistScheduleMapper.selectList(any())).thenReturn(List.of());
|
||||
when(artistScheduleRuleMapper.selectList(any())).thenReturn(List.of());
|
||||
when(appointmentReservationMapper.selectList(any())).thenReturn(List.of());
|
||||
|
||||
var calendar = planningService.getCalendar(manager, date, date, null);
|
||||
|
||||
assertThat(calendar.getArtists()).isEmpty();
|
||||
assertThat(calendar.getSchedules()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void calendarUsesRuleWhenDailyScheduleMissing() {
|
||||
UserDO manager = user(2, 8L);
|
||||
|
||||
Reference in New Issue
Block a user