From 369f58d24e4e006e915ffd1d6240453a162d0ce7 Mon Sep 17 00:00:00 2001 From: xiaowang <2161656029@qq.com> Date: Thu, 29 Oct 2026 18:32:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=AE=A2=E6=88=B7=E8=B5=84?= =?UTF-8?q?=E6=96=99=E4=B8=8E=E5=91=98=E5=B7=A5=E6=8E=92=E7=8F=AD=E6=94=B9?= =?UTF-8?q?=E9=80=A0=E9=98=B6=E6=AE=B5=E6=88=90=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PlanningServiceImpl.java | 1 + .../user/service/impl/UserServiceImpl.java | 14 +++- .../user/support/UserProfileFieldSupport.java | 5 +- .../impl/UserServiceCustomerMatchingTest.java | 76 +++++++++++++++++++ .../support/UserProfileFieldSupportTest.java | 20 +++++ .../pages/employee-create/index.js | 4 +- .../pages/employee-create/index.test.js | 12 ++- JC-Salon-WeChat/pages/planning/index.test.js | 17 ++++- JC-Salon-WeChat/pages/planning/index.wxml | 3 +- JC-Salon-WeChat/pages/planning/index.wxss | 15 +++- docs/项目变更记录.md | 3 + 11 files changed, 152 insertions(+), 18 deletions(-) create mode 100644 JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceCustomerMatchingTest.java create mode 100644 JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupportTest.java diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java index ab3201b4..d6ef017c 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/planning/service/impl/PlanningServiceImpl.java @@ -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; diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java index 0ffc6eb4..800f544e 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceImpl.java @@ -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 implements private void addPhoneMatch(LambdaQueryWrapper wrapper, String phone) { String hash = phoneCrypto.index(phone.trim()); List legacyIds = new ArrayList<>(); - Long legacyPhoneId = userMapper.findLegacyIdByPhone(phone.trim()); - if (legacyPhoneId != null) legacyIds.add(legacyPhoneId); + QueryWrapper 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); } diff --git a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupport.java b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupport.java index 63180c62..394a6909 100644 --- a/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupport.java +++ b/JC-Salon-Core/src/main/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupport.java @@ -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("店长的微信号不能为空"); } } } diff --git a/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceCustomerMatchingTest.java b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceCustomerMatchingTest.java new file mode 100644 index 00000000..02c3d468 --- /dev/null +++ b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/service/impl/UserServiceCustomerMatchingTest.java @@ -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> queries = org.mockito.ArgumentCaptor.forClass((Class) Wrapper.class); + verify(userMapper, times(2)).selectList(queries.capture()); + QueryWrapper legacyPhoneQuery = (QueryWrapper) 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()); + } +} diff --git a/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupportTest.java b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupportTest.java new file mode 100644 index 00000000..40ed6d5c --- /dev/null +++ b/JC-Salon-Core/src/test/java/com/xiaowang/jayucloud/salon/core/modules/user/support/UserProfileFieldSupportTest.java @@ -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)); + } +} diff --git a/JC-Salon-WeChat/pages/employee-create/index.js b/JC-Salon-WeChat/pages/employee-create/index.js index 5f960386..0a02c3f2 100644 --- a/JC-Salon-WeChat/pages/employee-create/index.js +++ b/JC-Salon-WeChat/pages/employee-create/index.js @@ -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: '默认排班设置失败', diff --git a/JC-Salon-WeChat/pages/employee-create/index.test.js b/JC-Salon-WeChat/pages/employee-create/index.test.js index 8cfe1bcc..3e3b00a6 100644 --- a/JC-Salon-WeChat/pages/employee-create/index.test.js +++ b/JC-Salon-WeChat/pages/employee-create/index.test.js @@ -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 diff --git a/JC-Salon-WeChat/pages/planning/index.test.js b/JC-Salon-WeChat/pages/planning/index.test.js index 67c7de2f..d4c8fa01 100644 --- a/JC-Salon-WeChat/pages/planning/index.test.js +++ b/JC-Salon-WeChat/pages/planning/index.test.js @@ -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 diff --git a/JC-Salon-WeChat/pages/planning/index.wxml b/JC-Salon-WeChat/pages/planning/index.wxml index 3a67550b..103d4d13 100644 --- a/JC-Salon-WeChat/pages/planning/index.wxml +++ b/JC-Salon-WeChat/pages/planning/index.wxml @@ -95,10 +95,10 @@ {{item.name}} + {{block.customerName}} {{block.timeText}} · {{block.productTitle}} - {{block.statusText}} @@ -108,7 +108,6 @@ 完成 - {{item.emptyText || '全天可约'}} diff --git a/JC-Salon-WeChat/pages/planning/index.wxss b/JC-Salon-WeChat/pages/planning/index.wxss index 2a4c179e..2e87601f 100644 --- a/JC-Salon-WeChat/pages/planning/index.wxss +++ b/JC-Salon-WeChat/pages/planning/index.wxss @@ -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; diff --git a/docs/项目变更记录.md b/docs/项目变更记录.md index f36d38dd..2b69eb50 100644 --- a/docs/项目变更记录.md +++ b/docs/项目变更记录.md @@ -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。