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

This commit is contained in:
2026-10-29 18:32:45 +08:00
parent 762be0d907
commit 369f58d24e
11 changed files with 152 additions and 18 deletions
@@ -41,6 +41,7 @@ import com.xiaowang.jayucloud.salon.core.modules.planning.vo.PlanningDaySummaryV
import com.xiaowang.jayucloud.salon.core.modules.planning.vo.PlanningScheduleVO;
import com.xiaowang.jayucloud.salon.core.modules.planning.vo.PlanningTodayOverviewVO;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -1,6 +1,7 @@
package com.xiaowang.jayucloud.salon.core.modules.user.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -3325,8 +3326,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
private void addPhoneMatch(LambdaQueryWrapper<UserDO> wrapper, String phone) {
String hash = phoneCrypto.index(phone.trim());
List<Long> legacyIds = new ArrayList<>();
Long legacyPhoneId = userMapper.findLegacyIdByPhone(phone.trim());
if (legacyPhoneId != null) legacyIds.add(legacyPhoneId);
QueryWrapper<UserDO> legacyPhoneQuery = new QueryWrapper<>();
legacyPhoneQuery.select("id")
.eq("phone", phone.trim())
.isNull("phone_hash")
.eq("type", 0)
.eq("is_delete", 0);
for (UserDO legacyCustomer : userMapper.selectList(legacyPhoneQuery)) {
if (legacyCustomer.getId() != null && !legacyIds.contains(legacyCustomer.getId())) {
legacyIds.add(legacyCustomer.getId());
}
}
for (Long legacyContactId : userMapper.findLegacyIdsByContactPhone(phone.trim())) {
if (!legacyIds.contains(legacyContactId)) legacyIds.add(legacyContactId);
}
@@ -15,9 +15,8 @@ public final class UserProfileFieldSupport {
}
public static void requireWechatIdForServiceUser(Integer userType, String wechatId) {
if ((Integer.valueOf(2).equals(userType) || Integer.valueOf(3).equals(userType))
&& !StringUtils.hasText(wechatId)) {
throw new IllegalArgumentException("店长和美甲师的微信号不能为空");
if (Integer.valueOf(2).equals(userType) && !StringUtils.hasText(wechatId)) {
throw new IllegalArgumentException("店长的微信号不能为空");
}
}
}
@@ -0,0 +1,76 @@
package com.xiaowang.jayucloud.salon.core.modules.user.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xiaowang.jayucloud.salon.core.modules.user.entity.UserDO;
import com.xiaowang.jayucloud.salon.core.modules.user.mapper.UserMapper;
import com.xiaowang.jayucloud.salon.core.support.privacy.PhoneCrypto;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class UserServiceCustomerMatchingTest {
@Mock private UserMapper userMapper;
@Mock private PhoneCrypto phoneCrypto;
@InjectMocks private UserServiceImpl userService;
@Test
void findsLegacyCustomerPhoneWithoutUsingServicePhoneLookup() {
UserDO customer = new UserDO();
customer.setId(91L);
customer.setNickname("周女士");
customer.setType(0);
customer.setIsDelete(0);
customer.setPhone("13800138000");
when(phoneCrypto.index("13800138000")).thenReturn("phone-hash");
when(phoneCrypto.decrypt("13800138000")).thenReturn("13800138000");
when(userMapper.selectList(any(Wrapper.class))).thenReturn(List.of(customer), List.of(customer));
when(userMapper.findLegacyIdsByContactPhone("13800138000")).thenReturn(List.of());
assertEquals(1, userService.findCustomerMatches("周女士", "13800138000", null).size());
org.mockito.ArgumentCaptor<Wrapper<UserDO>> queries = org.mockito.ArgumentCaptor.forClass((Class) Wrapper.class);
verify(userMapper, times(2)).selectList(queries.capture());
QueryWrapper<UserDO> legacyPhoneQuery = (QueryWrapper<UserDO>) queries.getAllValues().get(0);
assertTrue(legacyPhoneQuery.getSqlSegment().contains("phone"));
assertTrue(legacyPhoneQuery.getSqlSegment().contains("phone_hash"));
assertTrue(legacyPhoneQuery.getSqlSegment().contains("type"));
assertTrue(legacyPhoneQuery.getParamNameValuePairs().containsValue("13800138000"));
}
@Test
void rejectsOnlyAnExactNameWechatAndPhoneDuplicate() throws Exception {
UserDO existing = new UserDO();
existing.setId(91L);
existing.setNickname("周女士");
existing.setWechatId("wx-existing");
existing.setPhone("encrypted-phone");
when(phoneCrypto.decrypt("encrypted-phone")).thenReturn("13800138000");
when(userMapper.selectList(any(Wrapper.class))).thenReturn(List.of(existing));
Method ensureUnique = UserServiceImpl.class.getDeclaredMethod(
"ensureCustomerUnique", String.class, String.class, String.class, Long.class);
ensureUnique.setAccessible(true);
ensureUnique.invoke(userService, "周女士", "wx-other", "13800138000", null);
InvocationTargetException duplicate = assertThrows(InvocationTargetException.class,
() -> ensureUnique.invoke(userService, "周女士", "wx-existing", "13800138000", null));
assertEquals("客户已存在,请选择已有客户", duplicate.getCause().getMessage());
}
}
@@ -0,0 +1,20 @@
package com.xiaowang.jayucloud.salon.core.modules.user.support;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
class UserProfileFieldSupportTest {
@Test
void nailArtistWechatIdIsOptional() {
assertDoesNotThrow(() -> UserProfileFieldSupport.requireWechatIdForServiceUser(3, null));
}
@Test
void managerWechatIdRemainsRequired() {
assertThrows(IllegalArgumentException.class,
() -> UserProfileFieldSupport.requireWechatIdForServiceUser(2, null));
}
}
@@ -129,7 +129,7 @@ Page({
url: `/pages/schedule-setting/index?${query.join('&')}`,
success: result => {
result.eventChannel.on('scheduleSaved', () => {
setTimeout(() => this.finishCreated(true, true), 250)
setTimeout(() => this.finishCreated(this.data.pickerMode, true), 250)
})
}
})
@@ -147,7 +147,7 @@ Page({
status: 1,
remark: '新建美甲师默认全天可预约,可在排班设置中调整'
}).then(() => {
this.finishCreated(!this.data.pickerMode, true)
this.finishCreated(this.data.pickerMode, true)
}).catch(error => {
wx.showModal({
title: '默认排班设置失败',
@@ -38,6 +38,7 @@ async function run() {
page.onInput({ currentTarget: { dataset: { field: 'phone' } }, detail: { value: '13900139000' } })
assert.strictEqual(page.data.form.account, 'staff_zhou')
assert.strictEqual(page.data.form.color, '#8FB89A')
Object.assign(page.data.form, {
nickname: '小周',
phone: '13800138000',
@@ -53,16 +54,19 @@ async function run() {
await page.submit()
assert.strictEqual(page.data.onboardingVisible, true)
assert.strictEqual(emitted, undefined)
let schedulePayload
page.data.pickerMode = true
employeesApi.saveScheduleRule = async payload => {
assert.deepStrictEqual(payload.workDays, [1, 2, 3, 4, 5, 6, 7])
assert.strictEqual(payload.startTime, '00:00')
assert.strictEqual(payload.endTime, '23:59')
schedulePayload = payload
}
page.skipFirstSchedule()
await new Promise(resolve => setImmediate(resolve))
assert.deepStrictEqual(schedulePayload.workDays, [1, 2, 3, 4, 5, 6, 7])
assert.strictEqual(schedulePayload.startTime, '00:00')
assert.strictEqual(schedulePayload.endTime, '23:59')
assert.strictEqual(emitted.name, 'employeeCreated')
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: false, scheduleSaved: false })
assert.deepStrictEqual(emitted.value, { id: 88, name: '小周', title: '小周', avatar: '', autoSelect: true, scheduleSaved: true })
assert.strictEqual(navigatedBack, true)
page.data.onboardingVisible = true
+15 -2
View File
@@ -90,8 +90,21 @@ async function run() {
assert.strictEqual(dayState.timelineHeight, 2934)
assert.strictEqual(dayState.hours.find(item => item.label === '14:00').top, 1014)
assert.strictEqual(dayState.dayLanes[0].blocks[0].height, 240)
assert.match(planningWxss, /background-size:\s*100% 240rpx/)
assert.match(planningWxss, /\.control-card\s*\{[^}]*padding:\s*12rpx 16rpx;/)
const shortAppointmentState = dayPage.buildDayView({
businessStartTime: '10:30',
businessEndTime: '11:30',
artists: [{ id: 1, name: '美甲师', color: '#000' }],
appointments: [{ orderItemId: 9, date: '2026-10-12', startTime: '2026-10-12 10:45:00', durationMinutes: 15, artistId: 1 }]
})
assert.strictEqual(shortAppointmentState.hours[0].top, 54)
assert.strictEqual(shortAppointmentState.hours[1].top, 294)
const shortAppointmentLane = shortAppointmentState.dayLanes.find(lane => lane.artistId === 1)
assert.strictEqual(shortAppointmentLane.blocks[0].height, 60)
assert.strictEqual(shortAppointmentLane.blocks[0].compact, true)
assert.match(planningWxml, /class="hour-line" style="top: \{\{hour\.top\}\}rpx;"/)
assert.match(planningWxml, /class="time-label" style="top: \{\{item\.top\}\}rpx;"/)
assert.doesNotMatch(planningWxss, /background-size:\s*100% 240rpx/)
assert.match(planningWxss, /\.control-card\s*\{[^}]*padding:\s*8rpx 14rpx;/)
const requestPage = createPage({ viewMode: 'day', currentDateText: '2026-10-11' })
let calendarRequests = 0
+1 -2
View File
@@ -95,10 +95,10 @@
<view class="chip-dot" style="background: {{item.color}};"></view>
<text>{{item.name}}</text>
</view>
<view wx:for="{{hours}}" wx:for-item="hour" wx:key="value" class="hour-line" style="top: {{hour.top}}rpx;"></view>
<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-meta">{{block.timeText}} · {{block.productTitle}}</text>
<view class="block-footer">
<view class="block-footer">
<text class="block-status">{{block.statusText}}</text>
<view class="block-actions" catchtap="stopTap">
@@ -108,7 +108,6 @@
<text wx:if="{{block.historicalBackfill && block.status === 4}}" data-id="{{block.orderItemId}}" data-status="2" catchtap="quickUpdateStatus">完成</text>
</view>
</view>
</view>
</view>
<view wx:if="{{item.blocks.length === 0}}" class="lane-empty">{{item.emptyText || '全天可约'}}</view>
</view>
+12 -3
View File
@@ -344,9 +344,17 @@
position: relative;
flex-shrink: 0;
border-right: 1rpx solid #e7ece9;
background-image: linear-gradient(to bottom, rgba(203, 220, 213, 0.45) 1rpx, transparent 1rpx);
background-position: 0 54rpx;
background-size: 100% 240rpx;
background: #ffffff;
}
.hour-line {
position: absolute;
z-index: 0;
right: 0;
left: 0;
height: 1rpx;
background: rgba(203, 220, 213, 0.72);
pointer-events: none;
}
.lane-head {
@@ -365,6 +373,7 @@
.appointment-block {
position: absolute;
z-index: 1;
right: 12rpx;
left: 12rpx;
display: flex;
+3
View File
@@ -3,7 +3,10 @@
## 2026-10-29 Salon 客户建档与员工默认排班优化
- 规划日视图时间轴放大为每分钟4rpx,使30分钟预约卡片获得完整信息高度;收紧日期控制区和视图切换区的垂直留白。
- 日视图整点横线与时间标签共用同一组刻度数据逐条绘制,避免背景渐变重复间距造成偏移。
- 客户新增姓名必填、微信号和手机号选填并按姓名/微信号/手机号排列;客户可重名或复用联系方式,仅姓名、微信号、手机号组合完全相同时禁止建档,联系方式匹配按密文解密后的精确值校验。
- 客户精确手机号匹配兼容历史未加密数据;新建美甲师微信号改为选填,店长微信号仍为必填。
- 修复日历映射员工专属颜色时遗漏 `StringUtils` 导入导致的 Core 编译失败。
- 新建美甲师表单增加专属颜色,颜色保存在员工资料并显示到规划日历;微信号选填,登录账号随手机号自动带入,手动编辑账号后不再覆盖。
- 跳过首次排班引导时先写入每周七天00:00–23:59的常规规则,成功后才返回。
- 新增 Flyway V8 `JC-Salon-Core/src/main/resources/db/migration/V8__客户联系方式去重和美甲师专属颜色_20261029.sql`,移除客户手机号全局唯一索引,增加客户组合身份活动记录唯一索引及员工颜色字段;不修改冻结初始化 SQL。