保存客户与员工排班改造阶段成果

This commit is contained in:
2026-10-29 17:36:42 +08:00
parent b3a8c7e01c
commit 762be0d907
8 changed files with 66 additions and 32 deletions
@@ -370,10 +370,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createUser(UserDTO userDTO) { public Long createUser(UserDTO userDTO) {
return createUserInternal(userDTO, false); return createUserInternal(userDTO);
} }
private Long createUserInternal(UserDTO userDTO, boolean allowMissingCustomerPhone) { private Long createUserInternal(UserDTO userDTO) {
String validatedAccount = AccountValidationUtils.requireValidAccount(userDTO.getAccount()); String validatedAccount = AccountValidationUtils.requireValidAccount(userDTO.getAccount());
// 检查账号是否已存在 // 检查账号是否已存在
UserDO existingUser = findUserByAccount(validatedAccount); UserDO existingUser = findUserByAccount(validatedAccount);
@@ -390,7 +390,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
Long validatedShopId = pickPrimaryShopId(validatedShopIds); Long validatedShopId = pickPrimaryShopId(validatedShopIds);
Integer userType = userDTO.getType(); Integer userType = userDTO.getType();
String validatedPhone = Integer.valueOf(0).equals(userType) String validatedPhone = Integer.valueOf(0).equals(userType)
? validateCustomerPhone(userDTO.getPhone(), !(allowMissingCustomerPhone && Integer.valueOf(0).equals(userType))) ? validateCustomerPhone(userDTO.getPhone(), false)
: validateUserPhone(userDTO.getPhone(), null, true); : validateUserPhone(userDTO.getPhone(), null, true);
String validatedWechatId = UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId()); String validatedWechatId = UserProfileFieldSupport.normalizeOptionalText(userDTO.getWechatId());
if (Integer.valueOf(0).equals(userType)) { if (Integer.valueOf(0).equals(userType)) {
@@ -532,7 +532,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
customer.setShopIds(List.of(shopId)); customer.setShopIds(List.of(shopId));
customer.setLevel(VIP_LEVEL_NORMAL); customer.setLevel(VIP_LEVEL_NORMAL);
customer.setVipId(0L); customer.setVipId(0L);
return createUserInternal(customer, true); return createUserInternal(customer);
} }
@Override @Override
@@ -665,7 +665,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
userDO.setPassword(passwordEncoder.encode(userDTO.getPassword())); userDO.setPassword(passwordEncoder.encode(userDTO.getPassword()));
} }
if (userDTO.getPhone() != null) { if (userDTO.getPhone() != null) {
userDO.setPhone(validateUserPhone(userDTO.getPhone(), id, true)); userDO.setPhone(Integer.valueOf(0).equals(userDO.getType())
? validateCustomerPhone(userDTO.getPhone(), false)
: validateUserPhone(userDTO.getPhone(), id, true));
} }
if (userDTO.getContactPhone() != null) { if (userDTO.getContactPhone() != null) {
userDO.setContactPhone(UserProfileFieldSupport.normalizeOptionalText(userDTO.getContactPhone())); userDO.setContactPhone(UserProfileFieldSupport.normalizeOptionalText(userDTO.getContactPhone()));
@@ -733,6 +735,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
userDO.setCustomerIdentityHash(customerIdentityHash(userDO.getNickname(), userDO.getWechatId(), customerPhone)); userDO.setCustomerIdentityHash(customerIdentityHash(userDO.getNickname(), userDO.getWechatId(), customerPhone));
} else { } else {
userDO.setCustomerIdentityHash(null); userDO.setCustomerIdentityHash(null);
if (StringUtils.hasText(userDO.getPhone()) && !isDeletedPlaceholderPhone(userDO.getPhone())) {
ensurePhoneNotUsed(userDO.getPhone(), id);
}
} }
List<Long> validatedShopIds = null; List<Long> validatedShopIds = null;
boolean shopBindingChanged = userDTO.getShopIds() != null || userDTO.getShopId() != null; boolean shopBindingChanged = userDTO.getShopIds() != null || userDTO.getShopId() != null;
@@ -3234,6 +3239,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
private void ensurePhoneNotUsed(String phone, Long currentUserId) { private void ensurePhoneNotUsed(String phone, Long currentUserId) {
LambdaQueryWrapper<UserDO> wrapper = Wrappers.lambdaQuery(UserDO.class) LambdaQueryWrapper<UserDO> wrapper = Wrappers.lambdaQuery(UserDO.class)
.eq(UserDO::getPhoneHash, phoneCrypto.index(phone)) .eq(UserDO::getPhoneHash, phoneCrypto.index(phone))
.ne(UserDO::getType, 0)
.eq(UserDO::getIsDelete, 0); .eq(UserDO::getIsDelete, 0);
if (currentUserId != null) { if (currentUserId != null) {
wrapper.ne(UserDO::getId, currentUserId); wrapper.ne(UserDO::getId, currentUserId);
@@ -3347,6 +3353,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
String normalized = phone.trim(); String normalized = phone.trim();
UserDO user = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class) UserDO user = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class)
.eq(UserDO::getPhoneHash, phoneCrypto.index(normalized)) .eq(UserDO::getPhoneHash, phoneCrypto.index(normalized))
.ne(UserDO::getType, 0)
.eq(UserDO::getIsDelete, 0) .eq(UserDO::getIsDelete, 0)
.last("limit 1")); .last("limit 1"));
if (user == null) { if (user == null) {
@@ -93,6 +93,10 @@ CALL salon_v8_add_column_if_missing(
't_user', 'active_customer_identity_hash', 't_user', 'active_customer_identity_hash',
'char(64) GENERATED ALWAYS AS (CASE WHEN type = 0 AND COALESCE(is_delete, 0) = 0 THEN customer_identity_hash ELSE NULL END) STORED COMMENT ''有效客户组合身份索引''' 'char(64) GENERATED ALWAYS AS (CASE WHEN type = 0 AND COALESCE(is_delete, 0) = 0 THEN customer_identity_hash ELSE NULL END) STORED COMMENT ''有效客户组合身份索引'''
); );
CALL salon_v8_add_column_if_missing(
't_user', 'active_service_phone_hash',
'char(64) GENERATED ALWAYS AS (CASE WHEN type <> 0 AND COALESCE(is_delete, 0) = 0 THEN phone_hash ELSE NULL END) STORED COMMENT ''有效員工和管理員手机号唯一索引'''
);
CALL salon_v8_add_column_if_missing( CALL salon_v8_add_column_if_missing(
't_nail_artist_info', 'color', 't_nail_artist_info', 'color',
'varchar(7) NULL COMMENT ''美甲师规划专属颜色''' 'varchar(7) NULL COMMENT ''美甲师规划专属颜色'''
@@ -103,6 +107,9 @@ CALL salon_v8_add_index_if_missing('t_user', 'idx_user_phone_hash', '(`phone_has
CALL salon_v8_add_unique_index_if_missing( CALL salon_v8_add_unique_index_if_missing(
't_user', 'uk_user_active_customer_identity_hash', '(`active_customer_identity_hash`)' 't_user', 'uk_user_active_customer_identity_hash', '(`active_customer_identity_hash`)'
); );
CALL salon_v8_add_unique_index_if_missing(
't_user', 'uk_user_active_service_phone_hash', '(`active_service_phone_hash`)'
);
DROP PROCEDURE IF EXISTS salon_v8_add_column_if_missing; DROP PROCEDURE IF EXISTS salon_v8_add_column_if_missing;
DROP PROCEDURE IF EXISTS salon_v8_add_index_if_missing; DROP PROCEDURE IF EXISTS salon_v8_add_index_if_missing;
@@ -147,7 +147,7 @@ Page({
status: 1, status: 1,
remark: '新建美甲师默认全天可预约,可在排班设置中调整' remark: '新建美甲师默认全天可预约,可在排班设置中调整'
}).then(() => { }).then(() => {
this.finishCreated(!this.data.pickerMode, false) this.finishCreated(!this.data.pickerMode, true)
}).catch(error => { }).catch(error => {
wx.showModal({ wx.showModal({
title: '默认排班设置失败', title: '默认排班设置失败',
@@ -53,8 +53,9 @@
<view class="onboarding-icon">✓</view> <view class="onboarding-icon">✓</view>
<text class="onboarding-title">美甲师已创建</text> <text class="onboarding-title">美甲师已创建</text>
<text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。'}}</text> <text class="onboarding-desc">{{pickerMode ? '设置常规排班后,可继续把当前预约分配给该美甲师。' : '为新美甲师设置首个常规排班,之后即可正常承接预约。'}}</text>
<text class="onboarding-default-note">不立即设置时,将默认全年无休、全天可预约(00:00-23:59),之后可在排班设置中调整。</text>
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button> <button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置' : '稍后设置(默认全天可约)'}}</button> <button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(默认全天可约)' : '不设置,使用默认全天排班'}}</button>
</view> </view>
</view> </view>
</view> </view>
@@ -136,5 +136,6 @@
.onboarding-title { margin-top: 22rpx; color: #17211f; font-size: 32rpx; font-weight: 900; } .onboarding-title { margin-top: 22rpx; color: #17211f; font-size: 32rpx; font-weight: 900; }
.onboarding-desc { margin-top: 12rpx; color: #837b72; font-size: 23rpx; line-height: 1.7; text-align: center; } .onboarding-desc { margin-top: 12rpx; color: #837b72; font-size: 23rpx; line-height: 1.7; text-align: center; }
.onboarding-default-note { margin-top: 14rpx; padding: 14rpx 16rpx; border-radius: 12rpx; background: #eff7f2; color: #39705d; font-size: 21rpx; line-height: 1.55; text-align: left; }
.onboarding-primary { width: 100%; margin-top: 30rpx; } .onboarding-primary { width: 100%; margin-top: 30rpx; }
.onboarding-skip { margin-top: 12rpx; background: transparent; color: #7e776f; font-size: 23rpx; } .onboarding-skip { margin-top: 12rpx; background: transparent; color: #7e776f; font-size: 23rpx; }
+2 -2
View File
@@ -493,7 +493,7 @@ Page({
return { return {
...item, ...item,
top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight, top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: Math.max(100, (item.durationMinutes || 60) * minuteScale), height: Math.max(60, (item.durationMinutes || 60) * minuteScale),
compact: Number(item.durationMinutes || 60) <= 15, compact: Number(item.durationMinutes || 60) <= 15,
timeText: resolveAppointmentTimeText(item) timeText: resolveAppointmentTimeText(item)
} }
@@ -508,7 +508,7 @@ Page({
return { return {
...item, ...item,
top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight, top: Math.max(0, itemStart - startMinute) * minuteScale + laneHeaderHeight,
height: Math.max(100, (item.durationMinutes || 60) * minuteScale), height: Math.max(60, (item.durationMinutes || 60) * minuteScale),
compact: Number(item.durationMinutes || 60) <= 15, compact: Number(item.durationMinutes || 60) <= 15,
timeText: resolveAppointmentTimeText(item) timeText: resolveAppointmentTimeText(item)
} }
@@ -98,6 +98,8 @@
<view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}} {{block.compact ? 'compact' : ''}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment"> <view wx:for="{{item.blocks}}" wx:for-item="block" wx:key="orderItemId" class="appointment-block {{block.status === 0 ? 'pending' : ''}} {{block.compact ? 'compact' : ''}}" style="top: {{block.top}}rpx; height: {{block.height}}rpx; border-left-color: {{item.color}};" data-id="{{block.orderItemId}}" bindtap="openAppointment">
<text class="block-title">{{block.customerName}}</text> <text class="block-title">{{block.customerName}}</text>
<text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text> <text class="block-meta">{{block.timeText}} · {{block.productTitle}}</text>
<view class="block-footer">
<view class="block-footer">
<text class="block-status">{{block.statusText}}</text> <text class="block-status">{{block.statusText}}</text>
<view class="block-actions" catchtap="stopTap"> <view class="block-actions" catchtap="stopTap">
<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 && block.status === 0 && block.assignmentStatus !== 'UNASSIGNED'}}" data-id="{{block.orderItemId}}" data-status="1" catchtap="quickUpdateStatus">确认</text>
@@ -106,6 +108,8 @@
<text wx:if="{{block.historicalBackfill && block.status === 4}}" data-id="{{block.orderItemId}}" data-status="2" catchtap="quickUpdateStatus">完成</text> <text wx:if="{{block.historicalBackfill && block.status === 4}}" data-id="{{block.orderItemId}}" data-status="2" catchtap="quickUpdateStatus">完成</text>
</view> </view>
</view> </view>
</view>
</view>
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view> <view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
</view> </view>
</view> </view>
+31 -17
View File
@@ -72,7 +72,7 @@
} }
.control-card { .control-card {
padding: 12rpx 16rpx; padding: 8rpx 14rpx;
} }
.calendar-error-card { .calendar-error-card {
@@ -145,12 +145,12 @@
} }
.icon-btn.small { .icon-btn.small {
width: 52rpx; width: 44rpx;
min-width: 52rpx; min-width: 44rpx;
max-width: 52rpx; max-width: 44rpx;
height: 52rpx; height: 44rpx;
min-height: 52rpx; min-height: 44rpx;
font-size: 34rpx; font-size: 30rpx;
} }
.date-center { .date-center {
@@ -162,21 +162,21 @@
.date-main { .date-main {
color: #17211f; color: #17211f;
font-size: 32rpx; font-size: 30rpx;
font-weight: 800; font-weight: 800;
} }
.date-sub { .date-sub {
color: #71807a; color: #71807a;
font-size: 22rpx; font-size: 20rpx;
} }
.segmented { .segmented {
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
gap: 8rpx; gap: 8rpx;
margin-top: 10rpx; margin-top: 6rpx;
padding: 6rpx; padding: 4rpx;
border-radius: 12px; border-radius: 12px;
background: #f1ece4; background: #f1ece4;
} }
@@ -185,7 +185,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 46rpx; height: 40rpx;
border-radius: 10px; border-radius: 10px;
color: #7d756c; color: #7d756c;
font-size: 24rpx; font-size: 24rpx;
@@ -203,14 +203,15 @@
.artist-filter { .artist-filter {
display: flex; display: flex;
width: 100%; width: 100%;
margin-top: 10rpx; height: 44rpx;
margin-top: 6rpx;
white-space: nowrap; white-space: nowrap;
} }
.artist-chip { .artist-chip {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
height: 52rpx; height: 44rpx;
margin-right: 10rpx; margin-right: 10rpx;
padding: 0 16rpx; padding: 0 16rpx;
border-radius: 999rpx; border-radius: 999rpx;
@@ -242,8 +243,8 @@
.unassigned-notice { .unassigned-notice {
display: flex; display: flex;
align-items: center; align-items: center;
margin-top: 14rpx; margin-top: 8rpx;
padding: 14rpx 16rpx; padding: 10rpx 12rpx;
border-radius: 12rpx; border-radius: 12rpx;
background: #fff4e5; background: #fff4e5;
color: #8b5e24; color: #8b5e24;
@@ -344,6 +345,7 @@
flex-shrink: 0; flex-shrink: 0;
border-right: 1rpx solid #e7ece9; border-right: 1rpx solid #e7ece9;
background-image: linear-gradient(to bottom, rgba(203, 220, 213, 0.45) 1rpx, transparent 1rpx); background-image: linear-gradient(to bottom, rgba(203, 220, 213, 0.45) 1rpx, transparent 1rpx);
background-position: 0 54rpx;
background-size: 100% 240rpx; background-size: 100% 240rpx;
} }
@@ -367,6 +369,7 @@
left: 12rpx; left: 12rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
box-sizing: border-box;
gap: 2rpx; gap: 2rpx;
overflow: hidden; overflow: hidden;
padding: 6rpx 10rpx; padding: 6rpx 10rpx;
@@ -400,10 +403,17 @@
line-height: 1.25; line-height: 1.25;
} }
.block-footer {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 18rpx;
}
.block-actions { .block-actions {
display: flex; display: flex;
gap: 10rpx; gap: 10rpx;
margin-top: 2rpx; margin-top: 0;
color: #247b63; color: #247b63;
font-size: 18rpx; font-size: 18rpx;
font-weight: 800; font-weight: 800;
@@ -433,6 +443,10 @@
display: none; display: none;
} }
.appointment-block.compact .block-footer {
display: none;
}
.lane-empty { .lane-empty {
position: absolute; position: absolute;
top: 76rpx; top: 76rpx;